{"record":{"id":"32f3e946c3b961f4","repo":"gatsbyjs/gatsby","slug":"the-graphql-query-in-the-non-page-component-com","errorCode":null,"errorMessage":"The GraphQL query in the non-page component \"${component}\" will not be run.","messagePattern":"The GraphQL query in the non-page component \"(.+?)\" will not be run\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/query/query-watcher.ts","lineNumber":274,"sourceCode":"    )\n  })\n\n  let queriesWillNotRun = false\n  queries.forEach((query, component) => {\n    const queryWillRun = handleQuery(snapshot, query, component)\n\n    if (queryWillRun) {\n      watchComponent(component)\n      // Check if this is a page component.\n      // If it is and this is our first run during bootstrap,\n      // show a warning about having a query in a non-page component.\n    } else if (\n      isFirstRun &&\n      !snapshot.componentsWithCleanFilePaths.has(\n        getPathToLayoutComponent(component)\n      )\n    ) {\n      report.warn(\n        `The GraphQL query in the non-page component \"${component}\" will not be run.`\n      )\n      queriesWillNotRun = true\n    }\n  })\n\n  if (queriesWillNotRun) {\n    report.log(report.stripIndent`\n\n        Exported queries are only executed for page components. It's possible you're trying to create pages in your gatsby-node.js and that's failing for some reason.\n\n        If the failing component is a regular component and not intended to be a page component, you generally want to use \"useStaticQuery\" (https://www.gatsbyjs.com/docs/how-to/querying-data/use-static-query/) instead of exporting a page query.\n\n        If you're more experienced with GraphQL, you can also export GraphQL fragments from components and compose the fragments in the Page component query and pass data down into the child component (https://www.gatsbyjs.com/docs/reference/graphql-data-layer/using-graphql-fragments/)\n\n      `)\n  }\n","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/e85d62f1779e353eaac1753211629a26d123e26c/packages/gatsby/src/query/query-watcher.ts#L256-L292","documentation":"In updateStateAndRunQueries (query watcher, first bootstrap run), a component that is not a page (not registered via createPage) exports a GraphQL page query. Gatsby only runs queries for page components (and static queries), so the query is skipped and this warning tells you it will never execute.","triggerScenarios":"Thrown at packages/gatsby/src/query/query-watcher.ts:274 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Register the component as a page via createPage in gatsby-node, or move the query into the actual page template","Convert the page query to useStaticQuery if the component is shared/non-page","Remove the exported query if it is unused"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e85d62f1779e353eaac1753211629a26d123e26c","analyzedAt":"2026-08-26T17:50:09.662Z","contentChangedAt":"2026-08-26T17:50:09.662Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}