( location: string, jsonContent: string, options: SchemaPrintOptions & ParseOptions, )
| 19 | } |
| 20 | |
| 21 | export function parseGraphQLJSON( |
| 22 | location: string, |
| 23 | jsonContent: string, |
| 24 | options: SchemaPrintOptions & ParseOptions, |
| 25 | ): Source { |
| 26 | let parsedJson = parseBOM(jsonContent); |
| 27 | |
| 28 | if (parsedJson.data) { |
| 29 | parsedJson = parsedJson.data; |
| 30 | } |
| 31 | |
| 32 | if (parsedJson.kind === 'Document') { |
| 33 | return { |
| 34 | location, |
| 35 | document: parsedJson, |
| 36 | }; |
| 37 | } else if (parsedJson.__schema) { |
| 38 | const schema = buildClientSchema(parsedJson, options); |
| 39 | |
| 40 | return { |
| 41 | location, |
| 42 | schema, |
| 43 | }; |
| 44 | } else if (typeof parsedJson === 'string') { |
| 45 | return { |
| 46 | location, |
| 47 | rawSDL: parsedJson, |
| 48 | }; |
| 49 | } |
| 50 | |
| 51 | throw new Error(`Not valid JSON content`); |
| 52 | } |
no test coverage detected
searching dependent graphs…