Spaces:
Paused
Paused
Download node_modules/graphql/validation/rules/KnownFragmentNamesRule.mjs from sam522/GenAI_Course: direct link, hf CLI and curl.
- Browser
- Download file 688 Bytes
-
https://huggingface.co/spaces/sam522/GenAI_Course/resolve/bbf0eafbb40cb551e2f40f8ad8a90a585be08221/node_modules/graphql/validation/rules/KnownFragmentNamesRule.mjs
- Command line
-
hf download hf://spaces/sam522/GenAI_Course@bbf0eafbb40cb551e2f40f8ad8a90a585be08221/node_modules/graphql/validation/rules/KnownFragmentNamesRule.mjs
-
curl -L -o KnownFragmentNamesRule.mjs https://huggingface.co/spaces/sam522/GenAI_Course/resolve/bbf0eafbb40cb551e2f40f8ad8a90a585be08221/node_modules/graphql/validation/rules/KnownFragmentNamesRule.mjs
688 Bytes
| import { GraphQLError } from '../../error/GraphQLError.mjs'; | |
| /** | |
| * Known fragment names | |
| * | |
| * A GraphQL document is only valid if all `...Fragment` fragment spreads refer | |
| * to fragments defined in the same document. | |
| * | |
| * See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined | |
| */ | |
| export function KnownFragmentNamesRule(context) { | |
| return { | |
| FragmentSpread(node) { | |
| const fragmentName = node.name.value; | |
| const fragment = context.getFragment(fragmentName); | |
| if (!fragment) { | |
| context.reportError( | |
| new GraphQLError(`Unknown fragment "${fragmentName}".`, { | |
| nodes: node.name, | |
| }), | |
| ); | |
| } | |
| }, | |
| }; | |
| } | |