UNPKG

4.18 kBTypeScriptView Raw
1import { GraphQLEnumType, GraphQLInputObjectType, GraphQLNamedType, GraphQLScalarType, visit } from 'graphql';
2export interface SchemaPrintOptions {
3 /**
4 * Descriptions are defined as preceding string literals, however an older
5 * experimental version of the SDL supported preceding comments as
6 * descriptions. Set to true to enable this deprecated behavior.
7 * This option is provided to ease adoption and will be removed in v16.
8 *
9 * Default: false
10 */
11 commentDescriptions?: boolean;
12 assumeValid?: boolean;
13}
14export interface GetDocumentNodeFromSchemaOptions {
15 pathToDirectivesInExtensions?: Array<string>;
16}
17export type PrintSchemaWithDirectivesOptions = SchemaPrintOptions & GetDocumentNodeFromSchemaOptions;
18export type Maybe<T> = null | undefined | T;
19export type Constructor<T> = new (...args: any[]) => T;
20export type PruneSchemaFilter = (type: GraphQLNamedType) => boolean;
21/**
22 * Options for removing unused types from the schema
23 */
24export interface PruneSchemaOptions {
25 /**
26 * Return true to skip pruning this type. This check will run first before any other options.
27 * This can be helpful for schemas that support type extensions like Apollo Federation.
28 */
29 skipPruning?: PruneSchemaFilter;
30 /**
31 * Set to `true` to skip pruning object types or interfaces with no no fields
32 */
33 skipEmptyCompositeTypePruning?: boolean;
34 /**
35 * Set to `true` to skip pruning interfaces that are not implemented by any
36 * other types
37 */
38 skipUnimplementedInterfacesPruning?: boolean;
39 /**
40 * Set to `true` to skip pruning empty unions
41 */
42 skipEmptyUnionPruning?: boolean;
43 /**
44 * Set to `true` to skip pruning unused types
45 */
46 skipUnusedTypesPruning?: boolean;
47}
48export type InputLeafValueTransformer = (type: GraphQLEnumType | GraphQLScalarType, originalValue: any) => any;
49export type InputObjectValueTransformer = (type: GraphQLInputObjectType, originalValue: Record<string, any>) => Record<string, any>;
50export type ASTVisitorKeyMap = Partial<Parameters<typeof visit>[2]>;
51export type DirectiveLocationEnum = typeof DirectiveLocation;
52export declare enum DirectiveLocation {
53 /** Request Definitions */
54 QUERY = "QUERY",
55 MUTATION = "MUTATION",
56 SUBSCRIPTION = "SUBSCRIPTION",
57 FIELD = "FIELD",
58 FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION",
59 FRAGMENT_SPREAD = "FRAGMENT_SPREAD",
60 INLINE_FRAGMENT = "INLINE_FRAGMENT",
61 VARIABLE_DEFINITION = "VARIABLE_DEFINITION",
62 /** Type System Definitions */
63 SCHEMA = "SCHEMA",
64 SCALAR = "SCALAR",
65 OBJECT = "OBJECT",
66 FIELD_DEFINITION = "FIELD_DEFINITION",
67 ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION",
68 INTERFACE = "INTERFACE",
69 UNION = "UNION",
70 ENUM = "ENUM",
71 ENUM_VALUE = "ENUM_VALUE",
72 INPUT_OBJECT = "INPUT_OBJECT",
73 INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION"
74}
75export type ExtensionsObject = Record<string, any>;
76export type ObjectTypeExtensions = {
77 type: 'object';
78 fields: Record<string, {
79 extensions: ExtensionsObject;
80 arguments: Record<string, ExtensionsObject>;
81 }>;
82};
83export type InputTypeExtensions = {
84 type: 'input';
85 fields: Record<string, {
86 extensions: ExtensionsObject;
87 }>;
88};
89export type InterfaceTypeExtensions = {
90 type: 'interface';
91 fields: Record<string, {
92 extensions: ExtensionsObject;
93 arguments: Record<string, ExtensionsObject>;
94 }>;
95};
96export type UnionTypeExtensions = {
97 type: 'union';
98};
99export type ScalarTypeExtensions = {
100 type: 'scalar';
101};
102export type EnumTypeExtensions = {
103 type: 'enum';
104 values: Record<string, ExtensionsObject>;
105};
106export type PossibleTypeExtensions = InputTypeExtensions | InterfaceTypeExtensions | ObjectTypeExtensions | UnionTypeExtensions | ScalarTypeExtensions | EnumTypeExtensions;
107export type SchemaExtensions = {
108 schemaExtensions: ExtensionsObject;
109 types: Record<string, {
110 extensions: ExtensionsObject;
111 } & PossibleTypeExtensions>;
112};
113export type DirectiveArgs = {
114 [name: string]: any;
115};
116export type DirectiveUsage = {
117 name: string;
118 args: DirectiveArgs;
119};