{"record":{"id":"50426dec554b1050","repo":"gatsbyjs/gatsby","slug":"it-appears-like-gatsby-is-misconfigured-gatsby-re","errorCode":null,"errorMessage":"It appears like Gatsby is misconfigured. Gatsby related `graphql` calls are supposed to only be evaluated at compile time, and then compiled away. Unfortunately, something went wrong and the query was left in the compiled code.\n\nUnless your site has a complex or custom babel/Gatsby configuration this is likely a bug in Gatsby.","messagePattern":"It appears like Gatsby is misconfigured\\. Gatsby related `graphql` calls are supposed to only be evaluated at compile time, and then compiled away\\. Unfortunately, something went wrong and the query was left in the compiled code\\.\n\nUnless your site has a complex or custom babel/Gatsby configuration this is likely a bug in Gatsby\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/cache-dir/gatsby-browser-entry.js","lineNumber":6,"sourceCode":"import loader from \"./loader\"\n\nconst prefetchPathname = loader.enqueue\n\nfunction graphql() {\n  throw new Error(\n    `It appears like Gatsby is misconfigured. Gatsby related \\`graphql\\` calls ` +\n      `are supposed to only be evaluated at compile time, and then compiled away. ` +\n      `Unfortunately, something went wrong and the query was left in the compiled code.\\n\\n` +\n      `Unless your site has a complex or custom babel/Gatsby configuration this is likely a bug in Gatsby.`\n  )\n}\n\nexport { default as PageRenderer } from \"./public-page-renderer\"\nexport { useScrollRestoration } from \"gatsby-react-router-scroll\"\nexport {\n  Link,\n  withPrefix,\n  withAssetPrefix,\n  navigate,\n  parsePath,\n} from \"gatsby-link\"\n\nexport { graphql, prefetchPathname }","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/cache-dir/gatsby-browser-entry.js#L1-L24","documentation":"Thrown by the graphql() function in gatsby-browser-entry.js. This function is a placeholder/stub that should be replaced at compile time by Gatsby's Babel plugin — graphql tag calls are compiled into static query result lookups. If the function executes at runtime, it means the Babel transform did not strip/replace the graphql call, indicating a misconfigured build.","triggerScenarios":"A graphql tagged-template call survives into the browser bundle. This happens when the Gatsby Babel preset/plugin is not applied to the file containing the graphql call — e.g. the file is outside the normal src directory, a custom babel.config.js overrides Gatsby's preset, or a third-party dependency contains a graphql tag.","commonSituations":"Custom babel.config.js that removes or reorders @babel/preset-react / the Gatsby preset, importing a graphql query from a node_modules package that Gatsby doesn't transform, or using a non-standard build setup (custom webpack config that bypasses the Babel pipeline).","solutions":["Remove or simplify custom babel.config.js / .babelrc — let Gatsby's default Babel config handle the graphql tag.","Ensure graphql queries are co-located in files under src/ that go through Gatsby's Babel pipeline, not imported from external packages.","If using a custom webpack config, verify the Babel loader includes the Gatsby preset for all JS/TS files with graphql tags.","Run `gatsby clean` and rebuild to ensure no stale compiled output persists."],"exampleFix":"// before — custom .babelrc overrides Gatsby preset\n{\n  \"presets\": [\"@babel/preset-env\", \"@babel/preset-react\"]\n}\n\n// after — extend Gatsby's babel config instead\n// .babelrc or babel.config.js\nmodule.exports = {\n  ...require('babel-preset-gatsby'),\n  // add only your extra plugins here\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not override Gatsby's Babel preset without extending it — use `babel-preset-gatsby` as a base.","Keep all graphql tagged queries in files under src/ processed by Gatsby's Babel pipeline.","Avoid importing graphql queries from node_modules packages.","Run `gatsby clean` after changing Babel config to clear stale compiled output."],"tags":["graphql","babel","build-config","compile-time","misconfiguration"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}