UNPKG

2.27 kBTypeScriptView Raw
1import { DefinitionNode, DocumentNode, ParseOptions } from 'graphql';
2import { CompareFn } from './utils.js';
3import { GetDocumentNodeFromSchemaOptions, TypeSource } from '@graphql-tools/utils';
4type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
5export interface Config extends ParseOptions, GetDocumentNodeFromSchemaOptions {
6 /**
7 * Produces `schema { query: ..., mutation: ..., subscription: ... }`
8 *
9 * Default: true
10 */
11 useSchemaDefinition?: boolean;
12 /**
13 * Creates schema definition, even when no types are available
14 * Produces: `schema { query: Query }`
15 *
16 * Default: false
17 */
18 forceSchemaDefinition?: boolean;
19 /**
20 * Throws an error on a merge conflict
21 *
22 * Default: false
23 */
24 throwOnConflict?: boolean;
25 /**
26 * Descriptions are defined as preceding string literals, however an older
27 * experimental version of the SDL supported preceding comments as
28 * descriptions. Set to true to enable this deprecated behavior.
29 * This option is provided to ease adoption and will be removed in v16.
30 *
31 * Default: false
32 */
33 commentDescriptions?: boolean;
34 /**
35 * Puts the next directive first.
36 *
37 * Default: false
38 *
39 * @example:
40 * Given:
41 * ```graphql
42 * type User { a: String @foo }
43 * type User { a: String @bar }
44 * ```
45 *
46 * Results:
47 * ```
48 * type User { a: @bar @foo }
49 * ```
50 */
51 reverseDirectives?: boolean;
52 exclusions?: string[];
53 sort?: boolean | CompareFn<string>;
54 convertExtensions?: boolean;
55 consistentEnumMerge?: boolean;
56 ignoreFieldConflicts?: boolean;
57}
58/**
59 * Merges multiple type definitions into a single `DocumentNode`
60 * @param types The type definitions to be merged
61 */
62export declare function mergeTypeDefs(typeSource: TypeSource): DocumentNode;
63export declare function mergeTypeDefs(typeSource: TypeSource, config?: Partial<Config> & {
64 commentDescriptions: true;
65}): string;
66export declare function mergeTypeDefs(typeSource: TypeSource, config?: Omit<Partial<Config>, 'commentDescriptions'>): DocumentNode;
67export declare function mergeGraphQLTypes(typeSource: TypeSource, config: Config): DefinitionNode[];
68export {};