{"record":{"id":"efa51e2f337cdf19","repo":"gatsbyjs/gatsby","slug":"babelpluginremovegraphqlqueries-graphql-syntax-er","errorCode":null,"errorMessage":"BabelPluginRemoveGraphQLQueries: GraphQL syntax error in query:\n\n${documentText}\n\nmessage:\n\n${originalError}","messagePattern":"BabelPluginRemoveGraphQLQueries: GraphQL syntax error in query:\n\n(.+?)\n\nmessage:\n\n(.+?)","errorType":"exception","errorClass":"GraphQLSyntaxError","httpStatus":null,"severity":"error","filePath":"packages/babel-plugin-remove-graphql-queries/src/index.ts","lineNumber":276,"sourceCode":"      quasis[1].loc?.start\n    )\n  }\n\n  const text: string = quasis[0].value.raw\n  const normalizedText: string = graphql.stripIgnoredCharacters(text)\n\n  const hash: number = murmurhash(normalizedText, 0)\n  const location = quasis[0].loc as SourceLocation | null\n\n  try {\n    const ast = graphql.parse(text)\n\n    if (ast.definitions.length === 0) {\n      throw new EmptyGraphQLTagError(location)\n    }\n    return { ast, text: normalizedText, hash, isGlobal }\n  } catch (err) {\n    throw new GraphQLSyntaxError(text, err, location)\n  }\n}\n\nfunction isUseStaticQuery(path: NodePath<CallExpression>): boolean {\n  const callee = path.node.callee\n  if (callee.type === `MemberExpression`) {\n    const property = callee.property as Identifier\n    if (property.name === `useStaticQuery`) {\n      return (path.get(`callee`).get(`object`) as NodePath).referencesImport(\n        `gatsby`,\n        ``\n      )\n    }\n    return false\n  }\n  if ((callee as Identifier).name === `useStaticQuery`) {\n    return path.get(`callee`).referencesImport(`gatsby`, ``)\n  }","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/babel-plugin-remove-graphql-queries/src/index.ts#L258-L294","documentation":"Thrown by `GraphQLSyntaxError` (index.ts:276) when `graphql.parse(text)` itself throws inside `getGraphQLTag`. The original parse error and the offending document text are wrapped so the build can surface file location and context. The original error is preserved on `originalError` and the source location on `templateLoc`.","triggerScenarios":"Any malformed GraphQL in a `graphql`...`` tag: missing braces, unbalanced parentheses, undefined directives, invalid field syntax, stray characters, unsupported GraphQL features.","commonSituations":"Hand-editing a query and breaking syntax; using GraphQL features not supported by the project's graphql version; merging queries incorrectly; trailing commas or JS-style syntax leaking into the query.","solutions":["Read `originalError` in the message — it pinpoints the syntax problem and line/column.","Paste the query into a GraphQL linting tool or GraphiQL to find the syntax error.","Fix the syntax and rebuild."],"exampleFix":"// before — missing closing brace\ngraphql`\n  query {\n    site { title }\n`\n\n// after\ngraphql`\n  query {\n    site { siteMetadata { title } }\n  }\n`","handlingStrategy":"try-catch","validationCode":"function graphqlParses(text) {\n  try { graphql.parse(text); return true } catch { return false }\n}","typeGuard":"function isGraphQLSyntaxError(e) {\n  return e instanceof GraphQLSyntaxError || /^BabelPluginRemoveGraphQLQueries: GraphQL syntax error/.test(e.message)\n}","tryCatchPattern":"try {\n  graphql.parse(queryText)\n} catch (e) {\n  // surface e to the user with line/column from originalError\n}","preventionTips":["Validate queries in GraphiQL before committing.","Use a GraphQL ESLint plugin to catch syntax errors at lint time.","Read originalError in the wrapped message for precise diagnostics."],"tags":["babel","graphql","syntax","parsing"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}