1 | import { GraphQLError } from "../../error/GraphQLError.mjs";
|
2 |
|
3 | /**
|
4 | * Known fragment names
|
5 | *
|
6 | * A GraphQL document is only valid if all `...Fragment` fragment spreads refer
|
7 | * to fragments defined in the same document.
|
8 | */
|
9 | export function KnownFragmentNamesRule(context) {
|
10 | return {
|
11 | FragmentSpread: function FragmentSpread(node) {
|
12 | var fragmentName = node.name.value;
|
13 | var fragment = context.getFragment(fragmentName);
|
14 |
|
15 | if (!fragment) {
|
16 | context.reportError(new GraphQLError("Unknown fragment \"".concat(fragmentName, "\"."), node.name));
|
17 | }
|
18 | }
|
19 | };
|
20 | }
|