MCPcopy
hub / github.com/graphql/graphiql / defaultSchemaLoader

Function defaultSchemaLoader

packages/monaco-graphql/src/schemaLoader.ts:4–31  ·  view source on GitHub ↗
(schemaConfig, parser)

Source from the content-addressed store, hash-verified

2import type { SchemaLoader } from './typings';
3
4export const defaultSchemaLoader: SchemaLoader = (schemaConfig, parser) => {
5 const {
6 schema,
7 documentAST,
8 introspectionJSON,
9 introspectionJSONString,
10 buildSchemaOptions,
11 documentString,
12 } = schemaConfig;
13 if (schema) {
14 return schema;
15 }
16 if (introspectionJSONString) {
17 const introspectionJSONResult = JSON.parse(introspectionJSONString);
18 return buildClientSchema(introspectionJSONResult, buildSchemaOptions);
19 }
20 if (documentString && parser) {
21 const docAST = parser(documentString);
22 return buildASTSchema(docAST, buildSchemaOptions);
23 }
24 if (introspectionJSON) {
25 return buildClientSchema(introspectionJSON, buildSchemaOptions);
26 }
27 if (documentAST) {
28 return buildASTSchema(documentAST, buildSchemaOptions);
29 }
30 throw new Error('no schema supplied');
31};

Callers

nothing calls this directly

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected