{"record":{"id":"c5d4d4ea6fe2d8dc","repo":"Kong/insomnia","slug":"found-usage-of-unknown-fragment-selection-name-v","errorCode":null,"errorMessage":"Found usage of unknown fragment ${selection.name.value}","messagePattern":"Found usage of unknown fragment (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/insomnia/src/ui/components/editors/body/prettify-graphql.mjs","lineNumber":99,"sourceCode":"const replaceFragments = (sourceNode, fragments) => {\n  if (isSelectionsEmpty(sourceNode)) {\n    return sourceNode;\n  }\n\n  const newNode = { ...sourceNode };\n\n  let foundFragments = [];\n\n  newNode.selectionSet.selections = newNode.selectionSet.selections.filter(selection => {\n    if (selection.kind !== Kind.FRAGMENT_SPREAD) {\n      return true;\n    }\n\n    if (!foundFragments.find(fragment => fragment.name.value === selection.name.value)) {\n      const fragment = fragments.find(fragment => fragment.name.value === selection.name.value);\n\n      if (!fragment) {\n        throw new Error(`Found usage of unknown fragment ${selection.name.value}`);\n      }\n\n      foundFragments = [...foundFragments, fragment];\n    }\n\n    return false;\n  });\n\n  newNode.selectionSet.selections = [\n    ...newNode.selectionSet.selections,\n    ...foundFragments.reduce((acc, fragment) => [...fragment.selectionSet.selections, ...acc], []),\n  ];\n\n  newNode.selectionSet.selections = newNode.selectionSet.selections.map(selection =>\n    replaceFragments(selection, fragments),\n  );\n\n  return newNode;","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia/src/ui/components/editors/body/prettify-graphql.mjs#L81-L117","documentation":"Thrown by replaceFragments in the GraphQL editor's prettify/inline pipeline: a selection is a FragmentSpread whose name has no matching definition in the supplied fragments list, so inlining that fragment is impossible. Indicates a query referencing an undefined fragment.","triggerScenarios":"Thrown at packages/insomnia/src/ui/components/editors/body/prettify-graphql.mjs:99 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Define the missing fragment (e.g. `fragment X on Type { ... }`) somewhere in the query document before inlining","Remove the fragment spread from the query if it is unused or unnecessary","Check for typos between the spread name and the fragment definition name"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d9bb2b0142600f21309832daea3317942d285984","analyzedAt":"2026-08-26T18:04:05.187Z","contentChangedAt":"2026-08-26T18:04:05.187Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}