{"record":{"id":"39d81fa6da4a6978","repo":"gatsbyjs/gatsby","slug":"encountered-an-error-parsing-the-provided-graphql","errorCode":null,"errorMessage":"Encountered an error parsing the provided GraphQL type definitions:\\n${message}\\n\\n${frame}\\n","messagePattern":"Encountered an error parsing the provided GraphQL type definitions:\\\\n(.+?)\\\\n\\\\n(.+?)\\\\n","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"packages/gatsby/src/schema/types/type-defs.js","lineNumber":37,"sourceCode":"    } catch (error) {\n      reportParsingError(error)\n    }\n  }\n  return typeOrTypeDef\n}\n\nconst reportParsingError = error => {\n  const { message, source, locations } = error\n\n  if (source && locations && locations.length) {\n    const { codeFrameColumns } = require(`@babel/code-frame`)\n\n    const frame = codeFrameColumns(\n      source.body,\n      { start: locations[0] },\n      { linesAbove: 5, linesBelow: 5 }\n    )\n    report.panic(\n      `Encountered an error parsing the provided GraphQL type definitions:\\n` +\n        message +\n        `\\n\\n` +\n        frame +\n        `\\n`\n    )\n  } else {\n    throw error\n  }\n}\n\n/**\n * Given a type definition, collects type names that should skip the inference process\n */\nconst typesWithoutInference = (typeNames = [], typeOrTypeDef) => {\n  if (typeof typeOrTypeDef === `string`) {\n    typeOrTypeDef = parseTypeDef(typeOrTypeDef)\n  }","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/schema/types/type-defs.js#L19-L55","documentation":"This error fires when Gatsby's GraphQL type-definition parser (backed by @babel/code-frame for context) encounters a syntax error in SDL passed to createTypes. The message includes the parser's error message and a code frame showing the offending location. If no source/locations are available, the raw error is re-thrown instead.","triggerScenarios":"Passing malformed GraphQL SDL string(s) to actions.createTypes() -- missing braces, invalid directive syntax, unbalanced parentheses, reserved keyword misuse, or concatenating multiple type strings incorrectly.","commonSituations":"A template literal in createTypes has a typo or unclosed brace. Dynamically generating SDL with a bug in the string builder. Copying SDL from a doc that got mangled. Plugin schema extension with invalid syntax.","solutions":["Read the code frame in the error output -- it pinpoints the exact line and column of the syntax error.","Validate your SDL string with a GraphQL playground or the graphql package's parse() before passing to createTypes.","Check for unbalanced braces, missing colons, invalid field types, and stray characters in the SDL template literal.","If building SDL dynamically, log the generated string and inspect it for correctness."],"exampleFix":"// before -- missing closing brace\nactions.createTypes(`\n  type Post {\n    title: String\n`)\n\n// after\nactions.createTypes(`\n  type Post {\n    title: String\n  }\n`)","handlingStrategy":"validation","validationCode":"// Validate SDL syntax before passing to createTypes\nconst { parse } = require('graphql')\n\nfunction validateSDL(sdlString) {\n  try {\n    parse(sdlString)\n    return { valid: true }\n  } catch (err) {\n    return { valid: false, error: err.message, locations: err.locations }\n  }\n}\n\nconst result = validateSDL(myTypeDefs)\nif (!result.valid) {\n  console.error('Invalid SDL:', result.error, result.locations)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate SDL with graphql.parse() before passing to createTypes.","Use a GraphQL IDE or editor with SDL syntax checking.","When building SDL dynamically, log the generated string for inspection."],"tags":["graphql","schema","sdl","syntax-error","createtypes"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}