Kong/insomnia · error · Error

Found usage of unknown fragment ${selection.name.value}

Error message

Found usage of unknown fragment ${selection.name.value}

What it means

Error "Found usage of unknown fragment ${selection.name.value}" thrown in Kong/insomnia.

Source

Thrown at packages/insomnia/src/ui/components/editors/body/prettify-graphql.mjs:99

const replaceFragments = (sourceNode, fragments) => {
  if (isSelectionsEmpty(sourceNode)) {
    return sourceNode;
  }

  const newNode = { ...sourceNode };

  let foundFragments = [];

  newNode.selectionSet.selections = newNode.selectionSet.selections.filter(selection => {
    if (selection.kind !== Kind.FRAGMENT_SPREAD) {
      return true;
    }

    if (!foundFragments.find(fragment => fragment.name.value === selection.name.value)) {
      const fragment = fragments.find(fragment => fragment.name.value === selection.name.value);

      if (!fragment) {
        throw new Error(`Found usage of unknown fragment ${selection.name.value}`);
      }

      foundFragments = [...foundFragments, fragment];
    }

    return false;
  });

  newNode.selectionSet.selections = [
    ...newNode.selectionSet.selections,
    ...foundFragments.reduce((acc, fragment) => [...fragment.selectionSet.selections, ...acc], []),
  ];

  newNode.selectionSet.selections = newNode.selectionSet.selections.map(selection =>
    replaceFragments(selection, fragments),
  );

  return newNode;

View on GitHub (pinned to d9bb2b0142)

When it happens

Trigger: Thrown at packages/insomnia/src/ui/components/editors/body/prettify-graphql.mjs:99 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Kong/insomnia@d9bb2b0142 (2026-08-26). Data as JSON: /api/errors/c5d4d4ea6fe2d8dc. Report an issue: GitHub.