UNPKG

1.79 kBTypeScriptView Raw
1import { Source, BaseLoaderOptions, Loader } from '@graphql-tools/utils';
2import { GraphQLTagPluckOptions } from '@graphql-tools/graphql-tag-pluck';
3export declare type CodeFileLoaderConfig = {
4 pluckConfig?: GraphQLTagPluckOptions;
5 noPluck?: boolean;
6 noRequire?: boolean;
7 /**
8 * Set to `true` to raise errors if any matched files are not valid GraphQL
9 */
10 noSilentErrors?: boolean;
11};
12/**
13 * Additional options for loading from a code file
14 */
15export declare type CodeFileLoaderOptions = {
16 require?: string | string[];
17} & CodeFileLoaderConfig & BaseLoaderOptions;
18/**
19 * This loader loads GraphQL documents and type definitions from code files
20 * using `graphql-tag-pluck`.
21 *
22 * ```js
23 * const documents = await loadDocuments('queries/*.js', {
24 * loaders: [
25 * new CodeFileLoader()
26 * ]
27 * });
28 * ```
29 *
30 * Supported extensions include: `.ts`, `.tsx`, `.js`, `.jsx`, `.vue`, `.svelte`
31 */
32export declare class CodeFileLoader implements Loader<CodeFileLoaderOptions> {
33 private config;
34 constructor(config?: CodeFileLoaderConfig);
35 private getMergedOptions;
36 canLoad(pointer: string, options: CodeFileLoaderOptions): Promise<boolean>;
37 canLoadSync(pointer: string, options: CodeFileLoaderOptions): boolean;
38 private _buildGlobs;
39 resolveGlobs(glob: string, options: CodeFileLoaderOptions): Promise<string[]>;
40 resolveGlobsSync(glob: string, options: CodeFileLoaderOptions): string[];
41 load(pointer: string, options: CodeFileLoaderOptions): Promise<Source[]>;
42 loadSync(pointer: string, options: CodeFileLoaderOptions): Source[] | null;
43 handleSinglePath(location: string, options: CodeFileLoaderOptions): Promise<Source[]>;
44 handleSinglePathSync(location: string, options: CodeFileLoaderOptions): Source[] | null;
45}