UNPKG

1.53 kBTypeScriptView Raw
1import { Source, Loader, BaseLoaderOptions } from '@graphql-tools/utils';
2/**
3 * Additional options for loading from a JSON file
4 */
5export interface JsonFileLoaderOptions extends BaseLoaderOptions {
6 /**
7 * Set to `true` to raise errors if any matched files are not valid GraphQL
8 */
9 noSilentErrors?: boolean;
10}
11/**
12 * This loader loads documents and type definitions from JSON files.
13 *
14 * The JSON file can be the result of an introspection query made against a schema:
15 *
16 * ```js
17 * const schema = await loadSchema('schema-introspection.json', {
18 * loaders: [
19 * new JsonFileLoader()
20 * ]
21 * });
22 * ```
23 *
24 * Or it can be a `DocumentNode` object representing a GraphQL document or type definitions:
25 *
26 * ```js
27 * const documents = await loadDocuments('queries/*.json', {
28 * loaders: [
29 * new GraphQLFileLoader()
30 * ]
31 * });
32 * ```
33 */
34export declare class JsonFileLoader implements Loader {
35 canLoad(pointer: string, options: JsonFileLoaderOptions): Promise<boolean>;
36 canLoadSync(pointer: string, options: JsonFileLoaderOptions): boolean;
37 private _buildGlobs;
38 resolveGlobs(glob: string, options: JsonFileLoaderOptions): Promise<string[]>;
39 resolveGlobsSync(glob: string, options: JsonFileLoaderOptions): string[];
40 load(pointer: string, options: JsonFileLoaderOptions): Promise<Source[]>;
41 loadSync(pointer: string, options: JsonFileLoaderOptions): Source[];
42 handleFileContent(normalizedFilePath: string, rawSDL: string, options: JsonFileLoaderOptions): Source;
43}