UNPKG

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