@graphitation/supermassive 3.12.0 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintcache +1 -1
- package/CHANGELOG.md +18 -2
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.d.ts +5 -1
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.d.ts.map +1 -1
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js +34 -20
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js.map +2 -2
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs +36 -23
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs.map +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
# Change Log - @graphitation/supermassive
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Mon, 05 Jan 2026 11:01:43 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.14.0
|
|
8
|
+
|
|
9
|
+
Mon, 05 Jan 2026 11:01:43 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- extractMinimalViableSchemaForRequestDocument include interface implementations (77059398+vejrj@users.noreply.github.com)
|
|
14
|
+
|
|
15
|
+
## 3.13.0
|
|
16
|
+
|
|
17
|
+
Mon, 08 Dec 2025 16:15:56 GMT
|
|
18
|
+
|
|
19
|
+
### Minor changes
|
|
20
|
+
|
|
21
|
+
- extractMinimalViableSChemaForRequestDocument now returns optional arguments even when they are not used (77059398+vejrj@users.noreply.github.com)
|
|
22
|
+
|
|
7
23
|
## 3.12.0
|
|
8
24
|
|
|
9
|
-
Fri, 07 Nov 2025 11:36:
|
|
25
|
+
Fri, 07 Nov 2025 11:36:34 GMT
|
|
10
26
|
|
|
11
27
|
### Minor changes
|
|
12
28
|
|
|
@@ -5,5 +5,9 @@ export type ExtractMinimalViableSchemaResult = {
|
|
|
5
5
|
unknownDirectives: DirectiveNode[];
|
|
6
6
|
fragmentSpreads: string[];
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type ExtractMinimalViableSchemaForRequestDocumentOptions = {
|
|
9
|
+
includeInterfaceImplementingTypes?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function extractMinimalViableSchemaForRequestDocument(schema: GraphQLSchema, requestDocument: DocumentNode, options?: ExtractMinimalViableSchemaForRequestDocumentOptions): ExtractMinimalViableSchemaResult;
|
|
12
|
+
export {};
|
|
9
13
|
//# sourceMappingURL=extractMinimalViableSchemaForRequestDocument.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractMinimalViableSchemaForRequestDocument.d.ts","sourceRoot":"","sources":["../../src/utilities/extractMinimalViableSchemaForRequestDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,YAAY,EAWZ,aAAa,EAcd,MAAM,SAAS,CAAC;AACjB,OAAO,
|
|
1
|
+
{"version":3,"file":"extractMinimalViableSchemaForRequestDocument.d.ts","sourceRoot":"","sources":["../../src/utilities/extractMinimalViableSchemaForRequestDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,YAAY,EAWZ,aAAa,EAcd,MAAM,SAAS,CAAC;AACjB,OAAO,EAyBL,iBAAiB,EAGlB,MAAM,sBAAsB,CAAC;AAY9B,MAAM,MAAM,gCAAgC,GAAG;IAC7C,WAAW,EAAE,iBAAiB,CAAC;IAC/B,iBAAiB,EAAE,aAAa,EAAE,CAAC;IACnC,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,KAAK,mDAAmD,GAAG;IACzD,iCAAiC,CAAC,EAAE,OAAO,CAAC;CAC7C,CAAC;AAEF,wBAAgB,4CAA4C,CAC1D,MAAM,EAAE,aAAa,EACrB,eAAe,EAAE,YAAY,EAC7B,OAAO,CAAC,EAAE,mDAAmD,GAC5D,gCAAgC,CA6FlC"}
|
|
@@ -27,11 +27,12 @@ var import_directives = require("../schema/directives");
|
|
|
27
27
|
var import_makeReadableErrorPath = require("./makeReadableErrorPath");
|
|
28
28
|
var import_reference = require("../schema/reference");
|
|
29
29
|
var import_invariant = require("../jsutils/invariant");
|
|
30
|
-
function extractMinimalViableSchemaForRequestDocument(schema, requestDocument) {
|
|
30
|
+
function extractMinimalViableSchemaForRequestDocument(schema, requestDocument, options) {
|
|
31
31
|
const types = {};
|
|
32
32
|
const directives = [];
|
|
33
33
|
const unknownDirectives = [];
|
|
34
34
|
const fragmentSpreads = [];
|
|
35
|
+
const includeInterfaceImplementingTypes = (options == null ? void 0 : options.includeInterfaceImplementingTypes) || false;
|
|
35
36
|
const typeInfo = new import_graphql.TypeInfo(schema);
|
|
36
37
|
(0, import_graphql.visit)(
|
|
37
38
|
requestDocument,
|
|
@@ -46,9 +47,21 @@ function extractMinimalViableSchemaForRequestDocument(schema, requestDocument) {
|
|
|
46
47
|
const field = typeInfo.getFieldDef();
|
|
47
48
|
assertExistingField(field, node, ancestors);
|
|
48
49
|
assertAllArgumentsAreDefined(field, node, ancestors);
|
|
49
|
-
const fieldDef = addField(typeDef, field
|
|
50
|
+
const fieldDef = addField(typeDef, field);
|
|
50
51
|
addReferencedOutputType(schema, types, (0, import_definition.getFieldTypeReference)(fieldDef));
|
|
51
52
|
addReferencedInputTypes(schema, types, (0, import_definition.getFieldArgs)(fieldDef));
|
|
53
|
+
if (includeInterfaceImplementingTypes && (0, import_graphql.isInterfaceType)(parentType)) {
|
|
54
|
+
const possibleTypes = schema.getPossibleTypes(parentType);
|
|
55
|
+
for (const implementingType of possibleTypes) {
|
|
56
|
+
const implementingTypeDef = types[implementingType.name];
|
|
57
|
+
if (implementingTypeDef) {
|
|
58
|
+
const implementingField = implementingType.getFields()[field.name];
|
|
59
|
+
if (implementingField) {
|
|
60
|
+
addField(implementingTypeDef, implementingField);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
52
65
|
},
|
|
53
66
|
Directive(node, _key, _parent, _path) {
|
|
54
67
|
if ((0, import_directives.isKnownDirective)(node.name.value)) {
|
|
@@ -59,18 +72,24 @@ function extractMinimalViableSchemaForRequestDocument(schema, requestDocument) {
|
|
|
59
72
|
unknownDirectives.push(node);
|
|
60
73
|
return;
|
|
61
74
|
}
|
|
62
|
-
addDirective(directives, directive
|
|
75
|
+
addDirective(directives, directive);
|
|
63
76
|
},
|
|
64
77
|
FragmentDefinition(node, _key, _parent, _path, ancestors) {
|
|
65
78
|
const type = typeInfo.getType();
|
|
66
79
|
assertCompositeType(type, node, ancestors);
|
|
67
80
|
addCompositeType(types, type);
|
|
81
|
+
if (includeInterfaceImplementingTypes) {
|
|
82
|
+
addImplementingTypes(schema, types, type);
|
|
83
|
+
}
|
|
68
84
|
},
|
|
69
85
|
InlineFragment(node, _key, _parent, _path, ancestors) {
|
|
70
86
|
if (node == null ? void 0 : node.typeCondition) {
|
|
71
87
|
const type = typeInfo.getType();
|
|
72
88
|
assertCompositeType(type, node, ancestors);
|
|
73
89
|
addCompositeType(types, type);
|
|
90
|
+
if (includeInterfaceImplementingTypes) {
|
|
91
|
+
addImplementingTypes(schema, types, type);
|
|
92
|
+
}
|
|
74
93
|
}
|
|
75
94
|
},
|
|
76
95
|
FragmentSpread(node) {
|
|
@@ -142,31 +161,26 @@ function addCompositeType(types, type) {
|
|
|
142
161
|
}
|
|
143
162
|
return types[type.name] = encodeCompositeType(type);
|
|
144
163
|
}
|
|
145
|
-
function
|
|
146
|
-
|
|
164
|
+
function addImplementingTypes(schema, types, type) {
|
|
165
|
+
if ((0, import_graphql.isInterfaceType)(type)) {
|
|
166
|
+
const possibleTypes = schema.getPossibleTypes(type);
|
|
167
|
+
for (const implementingType of possibleTypes) {
|
|
168
|
+
addCompositeType(types, implementingType);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function addField(type, field) {
|
|
147
173
|
const fields = (0, import_definition.getFields)(type);
|
|
148
|
-
|
|
149
|
-
const previouslyAddedArgs = (_a = (0, import_definition.getFieldArgs)(existingFieldDef)) != null ? _a : /* @__PURE__ */ Object.create(null);
|
|
150
|
-
const nodeArgs = new Set((_b = fieldNode.arguments) == null ? void 0 : _b.map((arg) => arg.name.value));
|
|
151
|
-
const argsFilter = (argDef) => Boolean(
|
|
152
|
-
previouslyAddedArgs[argDef.name] || (0, import_graphql.isNonNullType)(argDef.type) || argDef.defaultValue !== void 0 || nodeArgs.has(argDef.name)
|
|
153
|
-
);
|
|
154
|
-
return fields[field.name] = encodeFieldDef(field, argsFilter);
|
|
174
|
+
return fields[field.name] = encodeFieldDef(field);
|
|
155
175
|
}
|
|
156
|
-
function addDirective(directives, directive
|
|
157
|
-
var _a;
|
|
176
|
+
function addDirective(directives, directive) {
|
|
158
177
|
const name = directive.name;
|
|
159
178
|
let tuple = directives.find((d) => (0, import_definition.getDirectiveName)(d) === name);
|
|
160
179
|
if (!tuple) {
|
|
161
180
|
tuple = [directive.name, directive.locations.map(import_definition.encodeDirectiveLocation)];
|
|
162
181
|
directives.push(tuple);
|
|
163
182
|
}
|
|
164
|
-
const
|
|
165
|
-
const nodeArgs = new Set((_a = node.arguments) == null ? void 0 : _a.map((arg) => arg.name.value));
|
|
166
|
-
const argsFilter = (argDef) => Boolean(
|
|
167
|
-
(previouslyAddedArgs == null ? void 0 : previouslyAddedArgs[argDef.name]) || (0, import_graphql.isNonNullType)(argDef.type) || argDef.defaultValue !== void 0 || nodeArgs.has(argDef.name)
|
|
168
|
-
);
|
|
169
|
-
const [hasArgs, argsRecord] = encodeArguments(directive.args, argsFilter);
|
|
183
|
+
const [hasArgs, argsRecord] = encodeArguments(directive.args);
|
|
170
184
|
if (hasArgs) {
|
|
171
185
|
(0, import_definition.setDirectiveDefinitionArgs)(tuple, argsRecord);
|
|
172
186
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utilities/extractMinimalViableSchemaForRequestDocument.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ASTNode,\n DirectiveNode,\n DocumentNode,\n FieldNode,\n GraphQLArgument,\n GraphQLCompositeType,\n GraphQLDirective,\n GraphQLEnumType,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLOutputType,\n GraphQLScalarType,\n GraphQLSchema,\n isCompositeType,\n isEnumType,\n isInputObjectType,\n isNonNullType,\n isObjectType,\n isScalarType,\n isSpecifiedScalarType,\n isUnionType,\n Kind,\n TypeInfo,\n visit,\n visitWithTypeInfo,\n locatedError,\n} from \"graphql\";\nimport {\n CompositeTypeTuple,\n createEnumTypeDefinition,\n createInputObjectTypeDefinition,\n createInterfaceTypeDefinition,\n createObjectTypeDefinition,\n createScalarTypeDefinition,\n createUnionTypeDefinition,\n DirectiveDefinitionTuple,\n encodeDirectiveLocation,\n EnumTypeDefinitionTuple,\n FieldDefinition,\n getDirectiveDefinitionArgs,\n getDirectiveName,\n getFieldArgs,\n getFields,\n getFieldTypeReference,\n getInputObjectFields,\n getInputValueTypeReference,\n InputObjectTypeDefinitionTuple,\n InputValueDefinition,\n InputValueDefinitionRecord,\n InterfaceTypeDefinitionTuple,\n isUnionTypeDefinition,\n ObjectTypeDefinitionTuple,\n ScalarTypeDefinitionTuple,\n SchemaDefinitions,\n setDirectiveDefinitionArgs,\n TypeDefinitionsRecord,\n} from \"../schema/definition\";\nimport { isKnownDirective } from \"../schema/directives\";\nimport { makeReadableErrorPath } from \"./makeReadableErrorPath\";\nimport {\n inspectTypeReference,\n typeNameFromReference,\n TypeReference,\n typeReferenceFromName,\n} from \"../schema/reference\";\nimport { invariant } from \"../jsutils/invariant\";\nimport { Maybe } from \"../jsutils/Maybe\";\n\nexport type ExtractMinimalViableSchemaResult = {\n definitions: SchemaDefinitions;\n unknownDirectives: DirectiveNode[];\n fragmentSpreads: string[];\n};\n\nexport function extractMinimalViableSchemaForRequestDocument(\n schema: GraphQLSchema,\n requestDocument: DocumentNode,\n): ExtractMinimalViableSchemaResult {\n const types: TypeDefinitionsRecord = {};\n const directives: DirectiveDefinitionTuple[] = [];\n const unknownDirectives: DirectiveNode[] = [];\n const fragmentSpreads: string[] = [];\n\n const typeInfo = new TypeInfo(schema);\n visit(\n requestDocument,\n visitWithTypeInfo(typeInfo, {\n Field(node, _key, _parent, _path, ancestors): void {\n const parentType = typeInfo.getParentType();\n assertCompositeType(parentType, node, ancestors);\n\n const typeDef = addCompositeType(types, parentType);\n if (\n isUnionTypeDefinition(typeDef) ||\n node.name.value === \"__typename\"\n ) {\n return;\n }\n const field = typeInfo.getFieldDef();\n assertExistingField(field, node, ancestors);\n assertAllArgumentsAreDefined(field, node, ancestors);\n\n const fieldDef = addField(typeDef, field, node);\n addReferencedOutputType(schema, types, getFieldTypeReference(fieldDef));\n addReferencedInputTypes(schema, types, getFieldArgs(fieldDef));\n },\n Directive(node, _key, _parent, _path) {\n if (isKnownDirective(node.name.value)) {\n return;\n }\n const directive = typeInfo.getDirective();\n if (!directive) {\n // This happens whenever a directive is requested that hasn't been defined in schema\n unknownDirectives.push(node);\n return;\n }\n addDirective(directives, directive, node);\n },\n FragmentDefinition(node, _key, _parent, _path, ancestors): void {\n const type = typeInfo.getType();\n assertCompositeType(type, node, ancestors);\n addCompositeType(types, type);\n },\n InlineFragment(node, _key, _parent, _path, ancestors): void {\n if (node?.typeCondition) {\n const type = typeInfo.getType();\n assertCompositeType(type, node, ancestors);\n addCompositeType(types, type);\n }\n },\n FragmentSpread(node) {\n if (!fragmentSpreads.includes(node.name.value)) {\n fragmentSpreads.push(node.name.value);\n }\n },\n Argument() {\n // Perf: no need to visit arguments - they were handled by Field/Directive visitors\n return false;\n },\n }),\n );\n const definitions = directives.length ? { types, directives } : { types };\n return { definitions, unknownDirectives, fragmentSpreads };\n}\n\nfunction addReferencedOutputType(\n schema: GraphQLSchema,\n types: TypeDefinitionsRecord,\n typeRef: TypeReference,\n) {\n const name = typeNameFromReference(typeRef);\n const schemaType = schema.getType(name);\n\n if (!schemaType) {\n throw new Error(`Type ${name} not found in schema`);\n }\n if (types[name] || isSpecifiedScalarType(schemaType)) {\n // Assuming already added\n return;\n }\n if (isCompositeType(schemaType)) {\n addCompositeType(types, schemaType);\n } else if (isEnumType(schemaType)) {\n types[name] = encodeEnumType(schemaType);\n } else if (isScalarType(schemaType)) {\n types[name] = encodeScalarType(schemaType);\n } else {\n invariant(false, \"Got non-output type: \" + inspectTypeReference(typeRef));\n }\n}\n\nfunction addReferencedInputTypes(\n schema: GraphQLSchema,\n types: TypeDefinitionsRecord,\n inputValues: InputValueDefinitionRecord | undefined,\n): void {\n if (!inputValues) {\n return;\n }\n for (const inputValueDef of Object.values(inputValues)) {\n const typeRef = getInputValueTypeReference(inputValueDef);\n const name = typeNameFromReference(typeRef);\n const schemaType = schema.getType(name);\n\n if (!schemaType) {\n throw new Error(`Type ${name} not found in schema`);\n }\n if (types[name] || isSpecifiedScalarType(schemaType)) {\n // Assuming already fully added\n continue;\n }\n if (isInputObjectType(schemaType)) {\n const inputObjectDef = encodeInputObjectType(schemaType);\n types[name] = inputObjectDef;\n addReferencedInputTypes(\n schema,\n types,\n getInputObjectFields(inputObjectDef),\n );\n } else if (isEnumType(schemaType)) {\n types[name] = encodeEnumType(schemaType);\n } else if (isScalarType(schemaType)) {\n types[name] = encodeScalarType(schemaType);\n } else {\n invariant(false, \"Got non-input type: \" + inspectTypeReference(typeRef));\n }\n }\n}\n\nfunction addCompositeType(\n types: TypeDefinitionsRecord,\n type: GraphQLCompositeType,\n): CompositeTypeTuple {\n if (types[type.name]) {\n // TODO: double check that the kind match?\n return types[type.name] as CompositeTypeTuple;\n }\n return (types[type.name] = encodeCompositeType(type));\n}\n\nfunction addField(\n type: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n field: GraphQLField<unknown, unknown>,\n fieldNode: FieldNode,\n): FieldDefinition {\n const fields = getFields(type);\n\n const existingFieldDef: FieldDefinition = fields[field.name];\n const previouslyAddedArgs =\n getFieldArgs(existingFieldDef) ?? Object.create(null);\n\n const nodeArgs = new Set(fieldNode.arguments?.map((arg) => arg.name.value));\n\n const argsFilter = (argDef: GraphQLArgument) =>\n Boolean(\n previouslyAddedArgs[argDef.name] ||\n isNonNullType(argDef.type) ||\n argDef.defaultValue !== undefined ||\n nodeArgs.has(argDef.name),\n );\n\n return (fields[field.name] = encodeFieldDef(field, argsFilter));\n}\n\nfunction addDirective(\n directives: DirectiveDefinitionTuple[],\n directive: GraphQLDirective,\n node: DirectiveNode,\n) {\n const name = directive.name;\n let tuple = directives.find((d) => getDirectiveName(d) === name);\n if (!tuple) {\n tuple = [directive.name, directive.locations.map(encodeDirectiveLocation)];\n directives.push(tuple);\n }\n\n const previouslyAddedArgs = getDirectiveDefinitionArgs(tuple);\n const nodeArgs = new Set(node.arguments?.map((arg) => arg.name.value));\n\n const argsFilter = (argDef: GraphQLArgument) =>\n Boolean(\n previouslyAddedArgs?.[argDef.name] ||\n isNonNullType(argDef.type) ||\n argDef.defaultValue !== undefined ||\n nodeArgs.has(argDef.name),\n );\n const [hasArgs, argsRecord] = encodeArguments(directive.args, argsFilter);\n if (hasArgs) {\n setDirectiveDefinitionArgs(tuple, argsRecord);\n }\n return tuple;\n}\n\nfunction encodeCompositeType(type: GraphQLCompositeType): CompositeTypeTuple {\n if (isUnionType(type)) {\n return createUnionTypeDefinition(type.getTypes().map((type) => type.name));\n }\n const ifaces = type.getInterfaces().map((iface) => iface.name);\n return isObjectType(type)\n ? createObjectTypeDefinition({}, ifaces)\n : createInterfaceTypeDefinition({}, ifaces);\n}\n\nfunction encodeInputObjectType(\n type: GraphQLInputObjectType,\n): InputObjectTypeDefinitionTuple {\n const result = Object.create(null);\n for (const [fieldName, field] of Object.entries(type.getFields())) {\n result[fieldName] = encodeInputField(field);\n }\n return createInputObjectTypeDefinition(result);\n}\n\nfunction encodeInputField(field: GraphQLInputField): InputValueDefinition {\n const typeReference = typeReferenceFromName(field.type.toString());\n return field.defaultValue === undefined\n ? typeReference\n : [typeReference, field.defaultValue];\n}\n\nfunction encodeFieldDef(\n field: GraphQLField<unknown, unknown>,\n argumentsFilter?: (arg: GraphQLArgument) => boolean,\n): FieldDefinition {\n const typeReference = typeReferenceFromName(field.type.toString());\n const [hasArgs, argsRecord] = encodeArguments(field.args, argumentsFilter);\n return !hasArgs ? typeReference : [typeReference, argsRecord];\n}\n\nfunction encodeArguments(\n args: ReadonlyArray<GraphQLArgument>,\n argumentsFilter?: (arg: GraphQLArgument) => boolean,\n): [boolean, InputValueDefinitionRecord] {\n let hasArgs = false;\n const argsRecord: InputValueDefinitionRecord = {};\n for (const argDef of args) {\n if (argumentsFilter && !argumentsFilter(argDef)) {\n continue;\n }\n const typeReference = typeReferenceFromName(argDef.type.toString());\n argsRecord[argDef.name] =\n argDef.defaultValue === undefined\n ? typeReference\n : [typeReference, argDef.defaultValue];\n hasArgs = true;\n }\n return [hasArgs, argsRecord];\n}\n\nfunction encodeEnumType(type: GraphQLEnumType): EnumTypeDefinitionTuple {\n return createEnumTypeDefinition(type.getValues().map((v) => v.name));\n}\n\nfunction encodeScalarType(_type: GraphQLScalarType): ScalarTypeDefinitionTuple {\n return createScalarTypeDefinition();\n}\n\nfunction assertCompositeType(\n type: Maybe<GraphQLOutputType>,\n node: ASTNode,\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n): asserts type is GraphQLCompositeType {\n if (!type || !isCompositeType(type)) {\n const path =\n node.kind === Kind.FIELD\n ? makeReadableErrorPath(ancestors).join(\".\") + \".\" + node.name.value\n : makeReadableErrorPath(ancestors).join(\".\");\n throw locatedError(`Cannot find type for: ${path}`, [node]);\n }\n}\n\nfunction assertExistingField(\n field: Maybe<GraphQLField<unknown, unknown>>,\n node: FieldNode,\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n): asserts field is GraphQLField<unknown, unknown> {\n if (!field) {\n const path =\n makeReadableErrorPath(ancestors).join(\".\") + \".\" + node.name.value;\n throw locatedError(`Cannot find field: ${path}`, [node]);\n }\n}\n\nfunction assertAllArgumentsAreDefined(\n field: GraphQLField<unknown, unknown> | GraphQLDirective,\n node: FieldNode | DirectiveNode,\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n) {\n const defArgs = new Set(field.args.map((arg) => arg.name));\n for (const arg of node.arguments ?? []) {\n if (!defArgs.has(arg.name.value)) {\n const path =\n makeReadableErrorPath(ancestors).join(\".\") +\n \".\" +\n node.name.value +\n `(${arg.name.value}: ...)`;\n throw locatedError(`Cannot find type for argument: ${path}`, [arg]);\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBA4BO;AACP,
|
|
4
|
+
"sourcesContent": ["import {\n ASTNode,\n DirectiveNode,\n DocumentNode,\n FieldNode,\n GraphQLArgument,\n GraphQLCompositeType,\n GraphQLDirective,\n GraphQLEnumType,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLOutputType,\n GraphQLScalarType,\n GraphQLSchema,\n isCompositeType,\n isEnumType,\n isInputObjectType,\n isObjectType,\n isScalarType,\n isSpecifiedScalarType,\n isUnionType,\n Kind,\n TypeInfo,\n visit,\n visitWithTypeInfo,\n locatedError,\n isInterfaceType,\n} from \"graphql\";\nimport {\n CompositeTypeTuple,\n createEnumTypeDefinition,\n createInputObjectTypeDefinition,\n createInterfaceTypeDefinition,\n createObjectTypeDefinition,\n createScalarTypeDefinition,\n createUnionTypeDefinition,\n DirectiveDefinitionTuple,\n encodeDirectiveLocation,\n EnumTypeDefinitionTuple,\n FieldDefinition,\n getDirectiveName,\n getFieldArgs,\n getFields,\n getFieldTypeReference,\n getInputObjectFields,\n getInputValueTypeReference,\n InputObjectTypeDefinitionTuple,\n InputValueDefinition,\n InputValueDefinitionRecord,\n InterfaceTypeDefinitionTuple,\n isUnionTypeDefinition,\n ObjectTypeDefinitionTuple,\n ScalarTypeDefinitionTuple,\n SchemaDefinitions,\n setDirectiveDefinitionArgs,\n TypeDefinitionsRecord,\n} from \"../schema/definition\";\nimport { isKnownDirective } from \"../schema/directives\";\nimport { makeReadableErrorPath } from \"./makeReadableErrorPath\";\nimport {\n inspectTypeReference,\n typeNameFromReference,\n TypeReference,\n typeReferenceFromName,\n} from \"../schema/reference\";\nimport { invariant } from \"../jsutils/invariant\";\nimport { Maybe } from \"../jsutils/Maybe\";\n\nexport type ExtractMinimalViableSchemaResult = {\n definitions: SchemaDefinitions;\n unknownDirectives: DirectiveNode[];\n fragmentSpreads: string[];\n};\n\ntype ExtractMinimalViableSchemaForRequestDocumentOptions = {\n includeInterfaceImplementingTypes?: boolean;\n};\n\nexport function extractMinimalViableSchemaForRequestDocument(\n schema: GraphQLSchema,\n requestDocument: DocumentNode,\n options?: ExtractMinimalViableSchemaForRequestDocumentOptions,\n): ExtractMinimalViableSchemaResult {\n const types: TypeDefinitionsRecord = {};\n const directives: DirectiveDefinitionTuple[] = [];\n const unknownDirectives: DirectiveNode[] = [];\n const fragmentSpreads: string[] = [];\n\n const includeInterfaceImplementingTypes =\n options?.includeInterfaceImplementingTypes || false;\n\n const typeInfo = new TypeInfo(schema);\n visit(\n requestDocument,\n visitWithTypeInfo(typeInfo, {\n Field(node, _key, _parent, _path, ancestors): void {\n const parentType = typeInfo.getParentType();\n assertCompositeType(parentType, node, ancestors);\n\n const typeDef = addCompositeType(types, parentType);\n if (\n isUnionTypeDefinition(typeDef) ||\n node.name.value === \"__typename\"\n ) {\n return;\n }\n const field = typeInfo.getFieldDef();\n assertExistingField(field, node, ancestors);\n assertAllArgumentsAreDefined(field, node, ancestors);\n\n const fieldDef = addField(typeDef, field);\n addReferencedOutputType(schema, types, getFieldTypeReference(fieldDef));\n addReferencedInputTypes(schema, types, getFieldArgs(fieldDef));\n\n if (includeInterfaceImplementingTypes && isInterfaceType(parentType)) {\n const possibleTypes = schema.getPossibleTypes(parentType);\n for (const implementingType of possibleTypes) {\n const implementingTypeDef = types[implementingType.name] as\n | ObjectTypeDefinitionTuple\n | InterfaceTypeDefinitionTuple\n | undefined;\n\n if (implementingTypeDef) {\n const implementingField =\n implementingType.getFields()[field.name];\n if (implementingField) {\n addField(implementingTypeDef, implementingField);\n }\n }\n }\n }\n },\n Directive(node, _key, _parent, _path) {\n if (isKnownDirective(node.name.value)) {\n return;\n }\n const directive = typeInfo.getDirective();\n if (!directive) {\n // This happens whenever a directive is requested that hasn't been defined in schema\n unknownDirectives.push(node);\n return;\n }\n addDirective(directives, directive);\n },\n FragmentDefinition(node, _key, _parent, _path, ancestors): void {\n const type = typeInfo.getType();\n assertCompositeType(type, node, ancestors);\n addCompositeType(types, type);\n if (includeInterfaceImplementingTypes) {\n addImplementingTypes(schema, types, type);\n }\n },\n InlineFragment(node, _key, _parent, _path, ancestors): void {\n if (node?.typeCondition) {\n const type = typeInfo.getType();\n assertCompositeType(type, node, ancestors);\n addCompositeType(types, type);\n if (includeInterfaceImplementingTypes) {\n addImplementingTypes(schema, types, type);\n }\n }\n },\n FragmentSpread(node) {\n if (!fragmentSpreads.includes(node.name.value)) {\n fragmentSpreads.push(node.name.value);\n }\n },\n Argument() {\n // Perf: no need to visit arguments - they were handled by Field/Directive visitors\n return false;\n },\n }),\n );\n const definitions = directives.length ? { types, directives } : { types };\n return { definitions, unknownDirectives, fragmentSpreads };\n}\n\nfunction addReferencedOutputType(\n schema: GraphQLSchema,\n types: TypeDefinitionsRecord,\n typeRef: TypeReference,\n) {\n const name = typeNameFromReference(typeRef);\n const schemaType = schema.getType(name);\n\n if (!schemaType) {\n throw new Error(`Type ${name} not found in schema`);\n }\n if (types[name] || isSpecifiedScalarType(schemaType)) {\n // Assuming already added\n return;\n }\n if (isCompositeType(schemaType)) {\n addCompositeType(types, schemaType);\n } else if (isEnumType(schemaType)) {\n types[name] = encodeEnumType(schemaType);\n } else if (isScalarType(schemaType)) {\n types[name] = encodeScalarType(schemaType);\n } else {\n invariant(false, \"Got non-output type: \" + inspectTypeReference(typeRef));\n }\n}\n\nfunction addReferencedInputTypes(\n schema: GraphQLSchema,\n types: TypeDefinitionsRecord,\n inputValues: InputValueDefinitionRecord | undefined,\n): void {\n if (!inputValues) {\n return;\n }\n for (const inputValueDef of Object.values(inputValues)) {\n const typeRef = getInputValueTypeReference(inputValueDef);\n const name = typeNameFromReference(typeRef);\n const schemaType = schema.getType(name);\n\n if (!schemaType) {\n throw new Error(`Type ${name} not found in schema`);\n }\n if (types[name] || isSpecifiedScalarType(schemaType)) {\n // Assuming already fully added\n continue;\n }\n if (isInputObjectType(schemaType)) {\n const inputObjectDef = encodeInputObjectType(schemaType);\n types[name] = inputObjectDef;\n addReferencedInputTypes(\n schema,\n types,\n getInputObjectFields(inputObjectDef),\n );\n } else if (isEnumType(schemaType)) {\n types[name] = encodeEnumType(schemaType);\n } else if (isScalarType(schemaType)) {\n types[name] = encodeScalarType(schemaType);\n } else {\n invariant(false, \"Got non-input type: \" + inspectTypeReference(typeRef));\n }\n }\n}\n\nfunction addCompositeType(\n types: TypeDefinitionsRecord,\n type: GraphQLCompositeType,\n): CompositeTypeTuple {\n if (types[type.name]) {\n // TODO: double check that the kind match?\n return types[type.name] as CompositeTypeTuple;\n }\n return (types[type.name] = encodeCompositeType(type));\n}\n\nfunction addImplementingTypes(\n schema: GraphQLSchema,\n types: TypeDefinitionsRecord,\n type: GraphQLCompositeType,\n): void {\n if (isInterfaceType(type)) {\n const possibleTypes = schema.getPossibleTypes(type);\n for (const implementingType of possibleTypes) {\n addCompositeType(types, implementingType);\n }\n }\n}\n\nfunction addField(\n type: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n field: GraphQLField<unknown, unknown>,\n): FieldDefinition {\n const fields = getFields(type);\n\n return (fields[field.name] = encodeFieldDef(field));\n}\n\nfunction addDirective(\n directives: DirectiveDefinitionTuple[],\n directive: GraphQLDirective,\n) {\n const name = directive.name;\n let tuple = directives.find((d) => getDirectiveName(d) === name);\n if (!tuple) {\n tuple = [directive.name, directive.locations.map(encodeDirectiveLocation)];\n directives.push(tuple);\n }\n\n const [hasArgs, argsRecord] = encodeArguments(directive.args);\n if (hasArgs) {\n setDirectiveDefinitionArgs(tuple, argsRecord);\n }\n return tuple;\n}\n\nfunction encodeCompositeType(type: GraphQLCompositeType): CompositeTypeTuple {\n if (isUnionType(type)) {\n return createUnionTypeDefinition(type.getTypes().map((type) => type.name));\n }\n const ifaces = type.getInterfaces().map((iface) => iface.name);\n return isObjectType(type)\n ? createObjectTypeDefinition({}, ifaces)\n : createInterfaceTypeDefinition({}, ifaces);\n}\n\nfunction encodeInputObjectType(\n type: GraphQLInputObjectType,\n): InputObjectTypeDefinitionTuple {\n const result = Object.create(null);\n for (const [fieldName, field] of Object.entries(type.getFields())) {\n result[fieldName] = encodeInputField(field);\n }\n return createInputObjectTypeDefinition(result);\n}\n\nfunction encodeInputField(field: GraphQLInputField): InputValueDefinition {\n const typeReference = typeReferenceFromName(field.type.toString());\n return field.defaultValue === undefined\n ? typeReference\n : [typeReference, field.defaultValue];\n}\n\nfunction encodeFieldDef(\n field: GraphQLField<unknown, unknown>,\n argumentsFilter?: (arg: GraphQLArgument) => boolean,\n): FieldDefinition {\n const typeReference = typeReferenceFromName(field.type.toString());\n const [hasArgs, argsRecord] = encodeArguments(field.args, argumentsFilter);\n return !hasArgs ? typeReference : [typeReference, argsRecord];\n}\n\nfunction encodeArguments(\n args: ReadonlyArray<GraphQLArgument>,\n argumentsFilter?: (arg: GraphQLArgument) => boolean,\n): [boolean, InputValueDefinitionRecord] {\n let hasArgs = false;\n const argsRecord: InputValueDefinitionRecord = {};\n for (const argDef of args) {\n if (argumentsFilter && !argumentsFilter(argDef)) {\n continue;\n }\n const typeReference = typeReferenceFromName(argDef.type.toString());\n argsRecord[argDef.name] =\n argDef.defaultValue === undefined\n ? typeReference\n : [typeReference, argDef.defaultValue];\n hasArgs = true;\n }\n return [hasArgs, argsRecord];\n}\n\nfunction encodeEnumType(type: GraphQLEnumType): EnumTypeDefinitionTuple {\n return createEnumTypeDefinition(type.getValues().map((v) => v.name));\n}\n\nfunction encodeScalarType(_type: GraphQLScalarType): ScalarTypeDefinitionTuple {\n return createScalarTypeDefinition();\n}\n\nfunction assertCompositeType(\n type: Maybe<GraphQLOutputType>,\n node: ASTNode,\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n): asserts type is GraphQLCompositeType {\n if (!type || !isCompositeType(type)) {\n const path =\n node.kind === Kind.FIELD\n ? makeReadableErrorPath(ancestors).join(\".\") + \".\" + node.name.value\n : makeReadableErrorPath(ancestors).join(\".\");\n throw locatedError(`Cannot find type for: ${path}`, [node]);\n }\n}\n\nfunction assertExistingField(\n field: Maybe<GraphQLField<unknown, unknown>>,\n node: FieldNode,\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n): asserts field is GraphQLField<unknown, unknown> {\n if (!field) {\n const path =\n makeReadableErrorPath(ancestors).join(\".\") + \".\" + node.name.value;\n throw locatedError(`Cannot find field: ${path}`, [node]);\n }\n}\n\nfunction assertAllArgumentsAreDefined(\n field: GraphQLField<unknown, unknown> | GraphQLDirective,\n node: FieldNode | DirectiveNode,\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n) {\n const defArgs = new Set(field.args.map((arg) => arg.name));\n for (const arg of node.arguments ?? []) {\n if (!defArgs.has(arg.name.value)) {\n const path =\n makeReadableErrorPath(ancestors).join(\".\") +\n \".\" +\n node.name.value +\n `(${arg.name.value}: ...)`;\n throw locatedError(`Cannot find type for argument: ${path}`, [arg]);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBA4BO;AACP,wBA4BO;AACP,wBAAiC;AACjC,mCAAsC;AACtC,uBAKO;AACP,uBAA0B;AAanB,SAAS,6CACd,QACA,iBACA,SACkC;AAClC,QAAM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AK,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;AACzD,aAAW,QAAO,UAAK,cAAL,YAAkB,CAAC,GAAG;AACtC,QAAI,CAAC,QAAQ,IAAI,IAAI,KAAK,KAAK,GAAG;AAChC,YAAM,WACJ,oDAAsB,SAAS,EAAE,KAAK,GAAG,IACzC,MACA,KAAK,KAAK,QACV,IAAI,IAAI,KAAK;AACf,gBAAM,6BAAa,kCAAkC,QAAQ,CAAC,GAAG,CAAC;AAAA,IACpE;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["type"]
|
|
7
7
|
}
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
isCompositeType,
|
|
4
4
|
isEnumType,
|
|
5
5
|
isInputObjectType,
|
|
6
|
-
isNonNullType,
|
|
7
6
|
isObjectType,
|
|
8
7
|
isScalarType,
|
|
9
8
|
isSpecifiedScalarType,
|
|
@@ -12,7 +11,8 @@ import {
|
|
|
12
11
|
TypeInfo,
|
|
13
12
|
visit,
|
|
14
13
|
visitWithTypeInfo,
|
|
15
|
-
locatedError
|
|
14
|
+
locatedError,
|
|
15
|
+
isInterfaceType
|
|
16
16
|
} from "graphql";
|
|
17
17
|
import {
|
|
18
18
|
createEnumTypeDefinition,
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
createScalarTypeDefinition,
|
|
23
23
|
createUnionTypeDefinition,
|
|
24
24
|
encodeDirectiveLocation,
|
|
25
|
-
getDirectiveDefinitionArgs,
|
|
26
25
|
getDirectiveName,
|
|
27
26
|
getFieldArgs,
|
|
28
27
|
getFields,
|
|
@@ -40,11 +39,12 @@ import {
|
|
|
40
39
|
typeReferenceFromName
|
|
41
40
|
} from "../schema/reference.mjs";
|
|
42
41
|
import { invariant } from "../jsutils/invariant.mjs";
|
|
43
|
-
function extractMinimalViableSchemaForRequestDocument(schema, requestDocument) {
|
|
42
|
+
function extractMinimalViableSchemaForRequestDocument(schema, requestDocument, options) {
|
|
44
43
|
const types = {};
|
|
45
44
|
const directives = [];
|
|
46
45
|
const unknownDirectives = [];
|
|
47
46
|
const fragmentSpreads = [];
|
|
47
|
+
const includeInterfaceImplementingTypes = (options == null ? void 0 : options.includeInterfaceImplementingTypes) || false;
|
|
48
48
|
const typeInfo = new TypeInfo(schema);
|
|
49
49
|
visit(
|
|
50
50
|
requestDocument,
|
|
@@ -59,9 +59,21 @@ function extractMinimalViableSchemaForRequestDocument(schema, requestDocument) {
|
|
|
59
59
|
const field = typeInfo.getFieldDef();
|
|
60
60
|
assertExistingField(field, node, ancestors);
|
|
61
61
|
assertAllArgumentsAreDefined(field, node, ancestors);
|
|
62
|
-
const fieldDef = addField(typeDef, field
|
|
62
|
+
const fieldDef = addField(typeDef, field);
|
|
63
63
|
addReferencedOutputType(schema, types, getFieldTypeReference(fieldDef));
|
|
64
64
|
addReferencedInputTypes(schema, types, getFieldArgs(fieldDef));
|
|
65
|
+
if (includeInterfaceImplementingTypes && isInterfaceType(parentType)) {
|
|
66
|
+
const possibleTypes = schema.getPossibleTypes(parentType);
|
|
67
|
+
for (const implementingType of possibleTypes) {
|
|
68
|
+
const implementingTypeDef = types[implementingType.name];
|
|
69
|
+
if (implementingTypeDef) {
|
|
70
|
+
const implementingField = implementingType.getFields()[field.name];
|
|
71
|
+
if (implementingField) {
|
|
72
|
+
addField(implementingTypeDef, implementingField);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
65
77
|
},
|
|
66
78
|
Directive(node, _key, _parent, _path) {
|
|
67
79
|
if (isKnownDirective(node.name.value)) {
|
|
@@ -72,18 +84,24 @@ function extractMinimalViableSchemaForRequestDocument(schema, requestDocument) {
|
|
|
72
84
|
unknownDirectives.push(node);
|
|
73
85
|
return;
|
|
74
86
|
}
|
|
75
|
-
addDirective(directives, directive
|
|
87
|
+
addDirective(directives, directive);
|
|
76
88
|
},
|
|
77
89
|
FragmentDefinition(node, _key, _parent, _path, ancestors) {
|
|
78
90
|
const type = typeInfo.getType();
|
|
79
91
|
assertCompositeType(type, node, ancestors);
|
|
80
92
|
addCompositeType(types, type);
|
|
93
|
+
if (includeInterfaceImplementingTypes) {
|
|
94
|
+
addImplementingTypes(schema, types, type);
|
|
95
|
+
}
|
|
81
96
|
},
|
|
82
97
|
InlineFragment(node, _key, _parent, _path, ancestors) {
|
|
83
98
|
if (node == null ? void 0 : node.typeCondition) {
|
|
84
99
|
const type = typeInfo.getType();
|
|
85
100
|
assertCompositeType(type, node, ancestors);
|
|
86
101
|
addCompositeType(types, type);
|
|
102
|
+
if (includeInterfaceImplementingTypes) {
|
|
103
|
+
addImplementingTypes(schema, types, type);
|
|
104
|
+
}
|
|
87
105
|
}
|
|
88
106
|
},
|
|
89
107
|
FragmentSpread(node) {
|
|
@@ -155,31 +173,26 @@ function addCompositeType(types, type) {
|
|
|
155
173
|
}
|
|
156
174
|
return types[type.name] = encodeCompositeType(type);
|
|
157
175
|
}
|
|
158
|
-
function
|
|
159
|
-
|
|
176
|
+
function addImplementingTypes(schema, types, type) {
|
|
177
|
+
if (isInterfaceType(type)) {
|
|
178
|
+
const possibleTypes = schema.getPossibleTypes(type);
|
|
179
|
+
for (const implementingType of possibleTypes) {
|
|
180
|
+
addCompositeType(types, implementingType);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function addField(type, field) {
|
|
160
185
|
const fields = getFields(type);
|
|
161
|
-
|
|
162
|
-
const previouslyAddedArgs = (_a = getFieldArgs(existingFieldDef)) != null ? _a : /* @__PURE__ */ Object.create(null);
|
|
163
|
-
const nodeArgs = new Set((_b = fieldNode.arguments) == null ? void 0 : _b.map((arg) => arg.name.value));
|
|
164
|
-
const argsFilter = (argDef) => Boolean(
|
|
165
|
-
previouslyAddedArgs[argDef.name] || isNonNullType(argDef.type) || argDef.defaultValue !== void 0 || nodeArgs.has(argDef.name)
|
|
166
|
-
);
|
|
167
|
-
return fields[field.name] = encodeFieldDef(field, argsFilter);
|
|
186
|
+
return fields[field.name] = encodeFieldDef(field);
|
|
168
187
|
}
|
|
169
|
-
function addDirective(directives, directive
|
|
170
|
-
var _a;
|
|
188
|
+
function addDirective(directives, directive) {
|
|
171
189
|
const name = directive.name;
|
|
172
190
|
let tuple = directives.find((d) => getDirectiveName(d) === name);
|
|
173
191
|
if (!tuple) {
|
|
174
192
|
tuple = [directive.name, directive.locations.map(encodeDirectiveLocation)];
|
|
175
193
|
directives.push(tuple);
|
|
176
194
|
}
|
|
177
|
-
const
|
|
178
|
-
const nodeArgs = new Set((_a = node.arguments) == null ? void 0 : _a.map((arg) => arg.name.value));
|
|
179
|
-
const argsFilter = (argDef) => Boolean(
|
|
180
|
-
(previouslyAddedArgs == null ? void 0 : previouslyAddedArgs[argDef.name]) || isNonNullType(argDef.type) || argDef.defaultValue !== void 0 || nodeArgs.has(argDef.name)
|
|
181
|
-
);
|
|
182
|
-
const [hasArgs, argsRecord] = encodeArguments(directive.args, argsFilter);
|
|
195
|
+
const [hasArgs, argsRecord] = encodeArguments(directive.args);
|
|
183
196
|
if (hasArgs) {
|
|
184
197
|
setDirectiveDefinitionArgs(tuple, argsRecord);
|
|
185
198
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utilities/extractMinimalViableSchemaForRequestDocument.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ASTNode,\n DirectiveNode,\n DocumentNode,\n FieldNode,\n GraphQLArgument,\n GraphQLCompositeType,\n GraphQLDirective,\n GraphQLEnumType,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLOutputType,\n GraphQLScalarType,\n GraphQLSchema,\n isCompositeType,\n isEnumType,\n isInputObjectType,\n isNonNullType,\n isObjectType,\n isScalarType,\n isSpecifiedScalarType,\n isUnionType,\n Kind,\n TypeInfo,\n visit,\n visitWithTypeInfo,\n locatedError,\n} from \"graphql\";\nimport {\n CompositeTypeTuple,\n createEnumTypeDefinition,\n createInputObjectTypeDefinition,\n createInterfaceTypeDefinition,\n createObjectTypeDefinition,\n createScalarTypeDefinition,\n createUnionTypeDefinition,\n DirectiveDefinitionTuple,\n encodeDirectiveLocation,\n EnumTypeDefinitionTuple,\n FieldDefinition,\n getDirectiveDefinitionArgs,\n getDirectiveName,\n getFieldArgs,\n getFields,\n getFieldTypeReference,\n getInputObjectFields,\n getInputValueTypeReference,\n InputObjectTypeDefinitionTuple,\n InputValueDefinition,\n InputValueDefinitionRecord,\n InterfaceTypeDefinitionTuple,\n isUnionTypeDefinition,\n ObjectTypeDefinitionTuple,\n ScalarTypeDefinitionTuple,\n SchemaDefinitions,\n setDirectiveDefinitionArgs,\n TypeDefinitionsRecord,\n} from \"../schema/definition\";\nimport { isKnownDirective } from \"../schema/directives\";\nimport { makeReadableErrorPath } from \"./makeReadableErrorPath\";\nimport {\n inspectTypeReference,\n typeNameFromReference,\n TypeReference,\n typeReferenceFromName,\n} from \"../schema/reference\";\nimport { invariant } from \"../jsutils/invariant\";\nimport { Maybe } from \"../jsutils/Maybe\";\n\nexport type ExtractMinimalViableSchemaResult = {\n definitions: SchemaDefinitions;\n unknownDirectives: DirectiveNode[];\n fragmentSpreads: string[];\n};\n\nexport function extractMinimalViableSchemaForRequestDocument(\n schema: GraphQLSchema,\n requestDocument: DocumentNode,\n): ExtractMinimalViableSchemaResult {\n const types: TypeDefinitionsRecord = {};\n const directives: DirectiveDefinitionTuple[] = [];\n const unknownDirectives: DirectiveNode[] = [];\n const fragmentSpreads: string[] = [];\n\n const typeInfo = new TypeInfo(schema);\n visit(\n requestDocument,\n visitWithTypeInfo(typeInfo, {\n Field(node, _key, _parent, _path, ancestors): void {\n const parentType = typeInfo.getParentType();\n assertCompositeType(parentType, node, ancestors);\n\n const typeDef = addCompositeType(types, parentType);\n if (\n isUnionTypeDefinition(typeDef) ||\n node.name.value === \"__typename\"\n ) {\n return;\n }\n const field = typeInfo.getFieldDef();\n assertExistingField(field, node, ancestors);\n assertAllArgumentsAreDefined(field, node, ancestors);\n\n const fieldDef = addField(typeDef, field, node);\n addReferencedOutputType(schema, types, getFieldTypeReference(fieldDef));\n addReferencedInputTypes(schema, types, getFieldArgs(fieldDef));\n },\n Directive(node, _key, _parent, _path) {\n if (isKnownDirective(node.name.value)) {\n return;\n }\n const directive = typeInfo.getDirective();\n if (!directive) {\n // This happens whenever a directive is requested that hasn't been defined in schema\n unknownDirectives.push(node);\n return;\n }\n addDirective(directives, directive, node);\n },\n FragmentDefinition(node, _key, _parent, _path, ancestors): void {\n const type = typeInfo.getType();\n assertCompositeType(type, node, ancestors);\n addCompositeType(types, type);\n },\n InlineFragment(node, _key, _parent, _path, ancestors): void {\n if (node?.typeCondition) {\n const type = typeInfo.getType();\n assertCompositeType(type, node, ancestors);\n addCompositeType(types, type);\n }\n },\n FragmentSpread(node) {\n if (!fragmentSpreads.includes(node.name.value)) {\n fragmentSpreads.push(node.name.value);\n }\n },\n Argument() {\n // Perf: no need to visit arguments - they were handled by Field/Directive visitors\n return false;\n },\n }),\n );\n const definitions = directives.length ? { types, directives } : { types };\n return { definitions, unknownDirectives, fragmentSpreads };\n}\n\nfunction addReferencedOutputType(\n schema: GraphQLSchema,\n types: TypeDefinitionsRecord,\n typeRef: TypeReference,\n) {\n const name = typeNameFromReference(typeRef);\n const schemaType = schema.getType(name);\n\n if (!schemaType) {\n throw new Error(`Type ${name} not found in schema`);\n }\n if (types[name] || isSpecifiedScalarType(schemaType)) {\n // Assuming already added\n return;\n }\n if (isCompositeType(schemaType)) {\n addCompositeType(types, schemaType);\n } else if (isEnumType(schemaType)) {\n types[name] = encodeEnumType(schemaType);\n } else if (isScalarType(schemaType)) {\n types[name] = encodeScalarType(schemaType);\n } else {\n invariant(false, \"Got non-output type: \" + inspectTypeReference(typeRef));\n }\n}\n\nfunction addReferencedInputTypes(\n schema: GraphQLSchema,\n types: TypeDefinitionsRecord,\n inputValues: InputValueDefinitionRecord | undefined,\n): void {\n if (!inputValues) {\n return;\n }\n for (const inputValueDef of Object.values(inputValues)) {\n const typeRef = getInputValueTypeReference(inputValueDef);\n const name = typeNameFromReference(typeRef);\n const schemaType = schema.getType(name);\n\n if (!schemaType) {\n throw new Error(`Type ${name} not found in schema`);\n }\n if (types[name] || isSpecifiedScalarType(schemaType)) {\n // Assuming already fully added\n continue;\n }\n if (isInputObjectType(schemaType)) {\n const inputObjectDef = encodeInputObjectType(schemaType);\n types[name] = inputObjectDef;\n addReferencedInputTypes(\n schema,\n types,\n getInputObjectFields(inputObjectDef),\n );\n } else if (isEnumType(schemaType)) {\n types[name] = encodeEnumType(schemaType);\n } else if (isScalarType(schemaType)) {\n types[name] = encodeScalarType(schemaType);\n } else {\n invariant(false, \"Got non-input type: \" + inspectTypeReference(typeRef));\n }\n }\n}\n\nfunction addCompositeType(\n types: TypeDefinitionsRecord,\n type: GraphQLCompositeType,\n): CompositeTypeTuple {\n if (types[type.name]) {\n // TODO: double check that the kind match?\n return types[type.name] as CompositeTypeTuple;\n }\n return (types[type.name] = encodeCompositeType(type));\n}\n\nfunction addField(\n type: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n field: GraphQLField<unknown, unknown>,\n fieldNode: FieldNode,\n): FieldDefinition {\n const fields = getFields(type);\n\n const existingFieldDef: FieldDefinition = fields[field.name];\n const previouslyAddedArgs =\n getFieldArgs(existingFieldDef) ?? Object.create(null);\n\n const nodeArgs = new Set(fieldNode.arguments?.map((arg) => arg.name.value));\n\n const argsFilter = (argDef: GraphQLArgument) =>\n Boolean(\n previouslyAddedArgs[argDef.name] ||\n isNonNullType(argDef.type) ||\n argDef.defaultValue !== undefined ||\n nodeArgs.has(argDef.name),\n );\n\n return (fields[field.name] = encodeFieldDef(field, argsFilter));\n}\n\nfunction addDirective(\n directives: DirectiveDefinitionTuple[],\n directive: GraphQLDirective,\n node: DirectiveNode,\n) {\n const name = directive.name;\n let tuple = directives.find((d) => getDirectiveName(d) === name);\n if (!tuple) {\n tuple = [directive.name, directive.locations.map(encodeDirectiveLocation)];\n directives.push(tuple);\n }\n\n const previouslyAddedArgs = getDirectiveDefinitionArgs(tuple);\n const nodeArgs = new Set(node.arguments?.map((arg) => arg.name.value));\n\n const argsFilter = (argDef: GraphQLArgument) =>\n Boolean(\n previouslyAddedArgs?.[argDef.name] ||\n isNonNullType(argDef.type) ||\n argDef.defaultValue !== undefined ||\n nodeArgs.has(argDef.name),\n );\n const [hasArgs, argsRecord] = encodeArguments(directive.args, argsFilter);\n if (hasArgs) {\n setDirectiveDefinitionArgs(tuple, argsRecord);\n }\n return tuple;\n}\n\nfunction encodeCompositeType(type: GraphQLCompositeType): CompositeTypeTuple {\n if (isUnionType(type)) {\n return createUnionTypeDefinition(type.getTypes().map((type) => type.name));\n }\n const ifaces = type.getInterfaces().map((iface) => iface.name);\n return isObjectType(type)\n ? createObjectTypeDefinition({}, ifaces)\n : createInterfaceTypeDefinition({}, ifaces);\n}\n\nfunction encodeInputObjectType(\n type: GraphQLInputObjectType,\n): InputObjectTypeDefinitionTuple {\n const result = Object.create(null);\n for (const [fieldName, field] of Object.entries(type.getFields())) {\n result[fieldName] = encodeInputField(field);\n }\n return createInputObjectTypeDefinition(result);\n}\n\nfunction encodeInputField(field: GraphQLInputField): InputValueDefinition {\n const typeReference = typeReferenceFromName(field.type.toString());\n return field.defaultValue === undefined\n ? typeReference\n : [typeReference, field.defaultValue];\n}\n\nfunction encodeFieldDef(\n field: GraphQLField<unknown, unknown>,\n argumentsFilter?: (arg: GraphQLArgument) => boolean,\n): FieldDefinition {\n const typeReference = typeReferenceFromName(field.type.toString());\n const [hasArgs, argsRecord] = encodeArguments(field.args, argumentsFilter);\n return !hasArgs ? typeReference : [typeReference, argsRecord];\n}\n\nfunction encodeArguments(\n args: ReadonlyArray<GraphQLArgument>,\n argumentsFilter?: (arg: GraphQLArgument) => boolean,\n): [boolean, InputValueDefinitionRecord] {\n let hasArgs = false;\n const argsRecord: InputValueDefinitionRecord = {};\n for (const argDef of args) {\n if (argumentsFilter && !argumentsFilter(argDef)) {\n continue;\n }\n const typeReference = typeReferenceFromName(argDef.type.toString());\n argsRecord[argDef.name] =\n argDef.defaultValue === undefined\n ? typeReference\n : [typeReference, argDef.defaultValue];\n hasArgs = true;\n }\n return [hasArgs, argsRecord];\n}\n\nfunction encodeEnumType(type: GraphQLEnumType): EnumTypeDefinitionTuple {\n return createEnumTypeDefinition(type.getValues().map((v) => v.name));\n}\n\nfunction encodeScalarType(_type: GraphQLScalarType): ScalarTypeDefinitionTuple {\n return createScalarTypeDefinition();\n}\n\nfunction assertCompositeType(\n type: Maybe<GraphQLOutputType>,\n node: ASTNode,\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n): asserts type is GraphQLCompositeType {\n if (!type || !isCompositeType(type)) {\n const path =\n node.kind === Kind.FIELD\n ? makeReadableErrorPath(ancestors).join(\".\") + \".\" + node.name.value\n : makeReadableErrorPath(ancestors).join(\".\");\n throw locatedError(`Cannot find type for: ${path}`, [node]);\n }\n}\n\nfunction assertExistingField(\n field: Maybe<GraphQLField<unknown, unknown>>,\n node: FieldNode,\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n): asserts field is GraphQLField<unknown, unknown> {\n if (!field) {\n const path =\n makeReadableErrorPath(ancestors).join(\".\") + \".\" + node.name.value;\n throw locatedError(`Cannot find field: ${path}`, [node]);\n }\n}\n\nfunction assertAllArgumentsAreDefined(\n field: GraphQLField<unknown, unknown> | GraphQLDirective,\n node: FieldNode | DirectiveNode,\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n) {\n const defArgs = new Set(field.args.map((arg) => arg.name));\n for (const arg of node.arguments ?? []) {\n if (!defArgs.has(arg.name.value)) {\n const path =\n makeReadableErrorPath(ancestors).join(\".\") +\n \".\" +\n node.name.value +\n `(${arg.name.value}: ...)`;\n throw locatedError(`Cannot find type for argument: ${path}`, [arg]);\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";AAAA;AAAA,EAeE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,
|
|
4
|
+
"sourcesContent": ["import {\n ASTNode,\n DirectiveNode,\n DocumentNode,\n FieldNode,\n GraphQLArgument,\n GraphQLCompositeType,\n GraphQLDirective,\n GraphQLEnumType,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputObjectType,\n GraphQLOutputType,\n GraphQLScalarType,\n GraphQLSchema,\n isCompositeType,\n isEnumType,\n isInputObjectType,\n isObjectType,\n isScalarType,\n isSpecifiedScalarType,\n isUnionType,\n Kind,\n TypeInfo,\n visit,\n visitWithTypeInfo,\n locatedError,\n isInterfaceType,\n} from \"graphql\";\nimport {\n CompositeTypeTuple,\n createEnumTypeDefinition,\n createInputObjectTypeDefinition,\n createInterfaceTypeDefinition,\n createObjectTypeDefinition,\n createScalarTypeDefinition,\n createUnionTypeDefinition,\n DirectiveDefinitionTuple,\n encodeDirectiveLocation,\n EnumTypeDefinitionTuple,\n FieldDefinition,\n getDirectiveName,\n getFieldArgs,\n getFields,\n getFieldTypeReference,\n getInputObjectFields,\n getInputValueTypeReference,\n InputObjectTypeDefinitionTuple,\n InputValueDefinition,\n InputValueDefinitionRecord,\n InterfaceTypeDefinitionTuple,\n isUnionTypeDefinition,\n ObjectTypeDefinitionTuple,\n ScalarTypeDefinitionTuple,\n SchemaDefinitions,\n setDirectiveDefinitionArgs,\n TypeDefinitionsRecord,\n} from \"../schema/definition\";\nimport { isKnownDirective } from \"../schema/directives\";\nimport { makeReadableErrorPath } from \"./makeReadableErrorPath\";\nimport {\n inspectTypeReference,\n typeNameFromReference,\n TypeReference,\n typeReferenceFromName,\n} from \"../schema/reference\";\nimport { invariant } from \"../jsutils/invariant\";\nimport { Maybe } from \"../jsutils/Maybe\";\n\nexport type ExtractMinimalViableSchemaResult = {\n definitions: SchemaDefinitions;\n unknownDirectives: DirectiveNode[];\n fragmentSpreads: string[];\n};\n\ntype ExtractMinimalViableSchemaForRequestDocumentOptions = {\n includeInterfaceImplementingTypes?: boolean;\n};\n\nexport function extractMinimalViableSchemaForRequestDocument(\n schema: GraphQLSchema,\n requestDocument: DocumentNode,\n options?: ExtractMinimalViableSchemaForRequestDocumentOptions,\n): ExtractMinimalViableSchemaResult {\n const types: TypeDefinitionsRecord = {};\n const directives: DirectiveDefinitionTuple[] = [];\n const unknownDirectives: DirectiveNode[] = [];\n const fragmentSpreads: string[] = [];\n\n const includeInterfaceImplementingTypes =\n options?.includeInterfaceImplementingTypes || false;\n\n const typeInfo = new TypeInfo(schema);\n visit(\n requestDocument,\n visitWithTypeInfo(typeInfo, {\n Field(node, _key, _parent, _path, ancestors): void {\n const parentType = typeInfo.getParentType();\n assertCompositeType(parentType, node, ancestors);\n\n const typeDef = addCompositeType(types, parentType);\n if (\n isUnionTypeDefinition(typeDef) ||\n node.name.value === \"__typename\"\n ) {\n return;\n }\n const field = typeInfo.getFieldDef();\n assertExistingField(field, node, ancestors);\n assertAllArgumentsAreDefined(field, node, ancestors);\n\n const fieldDef = addField(typeDef, field);\n addReferencedOutputType(schema, types, getFieldTypeReference(fieldDef));\n addReferencedInputTypes(schema, types, getFieldArgs(fieldDef));\n\n if (includeInterfaceImplementingTypes && isInterfaceType(parentType)) {\n const possibleTypes = schema.getPossibleTypes(parentType);\n for (const implementingType of possibleTypes) {\n const implementingTypeDef = types[implementingType.name] as\n | ObjectTypeDefinitionTuple\n | InterfaceTypeDefinitionTuple\n | undefined;\n\n if (implementingTypeDef) {\n const implementingField =\n implementingType.getFields()[field.name];\n if (implementingField) {\n addField(implementingTypeDef, implementingField);\n }\n }\n }\n }\n },\n Directive(node, _key, _parent, _path) {\n if (isKnownDirective(node.name.value)) {\n return;\n }\n const directive = typeInfo.getDirective();\n if (!directive) {\n // This happens whenever a directive is requested that hasn't been defined in schema\n unknownDirectives.push(node);\n return;\n }\n addDirective(directives, directive);\n },\n FragmentDefinition(node, _key, _parent, _path, ancestors): void {\n const type = typeInfo.getType();\n assertCompositeType(type, node, ancestors);\n addCompositeType(types, type);\n if (includeInterfaceImplementingTypes) {\n addImplementingTypes(schema, types, type);\n }\n },\n InlineFragment(node, _key, _parent, _path, ancestors): void {\n if (node?.typeCondition) {\n const type = typeInfo.getType();\n assertCompositeType(type, node, ancestors);\n addCompositeType(types, type);\n if (includeInterfaceImplementingTypes) {\n addImplementingTypes(schema, types, type);\n }\n }\n },\n FragmentSpread(node) {\n if (!fragmentSpreads.includes(node.name.value)) {\n fragmentSpreads.push(node.name.value);\n }\n },\n Argument() {\n // Perf: no need to visit arguments - they were handled by Field/Directive visitors\n return false;\n },\n }),\n );\n const definitions = directives.length ? { types, directives } : { types };\n return { definitions, unknownDirectives, fragmentSpreads };\n}\n\nfunction addReferencedOutputType(\n schema: GraphQLSchema,\n types: TypeDefinitionsRecord,\n typeRef: TypeReference,\n) {\n const name = typeNameFromReference(typeRef);\n const schemaType = schema.getType(name);\n\n if (!schemaType) {\n throw new Error(`Type ${name} not found in schema`);\n }\n if (types[name] || isSpecifiedScalarType(schemaType)) {\n // Assuming already added\n return;\n }\n if (isCompositeType(schemaType)) {\n addCompositeType(types, schemaType);\n } else if (isEnumType(schemaType)) {\n types[name] = encodeEnumType(schemaType);\n } else if (isScalarType(schemaType)) {\n types[name] = encodeScalarType(schemaType);\n } else {\n invariant(false, \"Got non-output type: \" + inspectTypeReference(typeRef));\n }\n}\n\nfunction addReferencedInputTypes(\n schema: GraphQLSchema,\n types: TypeDefinitionsRecord,\n inputValues: InputValueDefinitionRecord | undefined,\n): void {\n if (!inputValues) {\n return;\n }\n for (const inputValueDef of Object.values(inputValues)) {\n const typeRef = getInputValueTypeReference(inputValueDef);\n const name = typeNameFromReference(typeRef);\n const schemaType = schema.getType(name);\n\n if (!schemaType) {\n throw new Error(`Type ${name} not found in schema`);\n }\n if (types[name] || isSpecifiedScalarType(schemaType)) {\n // Assuming already fully added\n continue;\n }\n if (isInputObjectType(schemaType)) {\n const inputObjectDef = encodeInputObjectType(schemaType);\n types[name] = inputObjectDef;\n addReferencedInputTypes(\n schema,\n types,\n getInputObjectFields(inputObjectDef),\n );\n } else if (isEnumType(schemaType)) {\n types[name] = encodeEnumType(schemaType);\n } else if (isScalarType(schemaType)) {\n types[name] = encodeScalarType(schemaType);\n } else {\n invariant(false, \"Got non-input type: \" + inspectTypeReference(typeRef));\n }\n }\n}\n\nfunction addCompositeType(\n types: TypeDefinitionsRecord,\n type: GraphQLCompositeType,\n): CompositeTypeTuple {\n if (types[type.name]) {\n // TODO: double check that the kind match?\n return types[type.name] as CompositeTypeTuple;\n }\n return (types[type.name] = encodeCompositeType(type));\n}\n\nfunction addImplementingTypes(\n schema: GraphQLSchema,\n types: TypeDefinitionsRecord,\n type: GraphQLCompositeType,\n): void {\n if (isInterfaceType(type)) {\n const possibleTypes = schema.getPossibleTypes(type);\n for (const implementingType of possibleTypes) {\n addCompositeType(types, implementingType);\n }\n }\n}\n\nfunction addField(\n type: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n field: GraphQLField<unknown, unknown>,\n): FieldDefinition {\n const fields = getFields(type);\n\n return (fields[field.name] = encodeFieldDef(field));\n}\n\nfunction addDirective(\n directives: DirectiveDefinitionTuple[],\n directive: GraphQLDirective,\n) {\n const name = directive.name;\n let tuple = directives.find((d) => getDirectiveName(d) === name);\n if (!tuple) {\n tuple = [directive.name, directive.locations.map(encodeDirectiveLocation)];\n directives.push(tuple);\n }\n\n const [hasArgs, argsRecord] = encodeArguments(directive.args);\n if (hasArgs) {\n setDirectiveDefinitionArgs(tuple, argsRecord);\n }\n return tuple;\n}\n\nfunction encodeCompositeType(type: GraphQLCompositeType): CompositeTypeTuple {\n if (isUnionType(type)) {\n return createUnionTypeDefinition(type.getTypes().map((type) => type.name));\n }\n const ifaces = type.getInterfaces().map((iface) => iface.name);\n return isObjectType(type)\n ? createObjectTypeDefinition({}, ifaces)\n : createInterfaceTypeDefinition({}, ifaces);\n}\n\nfunction encodeInputObjectType(\n type: GraphQLInputObjectType,\n): InputObjectTypeDefinitionTuple {\n const result = Object.create(null);\n for (const [fieldName, field] of Object.entries(type.getFields())) {\n result[fieldName] = encodeInputField(field);\n }\n return createInputObjectTypeDefinition(result);\n}\n\nfunction encodeInputField(field: GraphQLInputField): InputValueDefinition {\n const typeReference = typeReferenceFromName(field.type.toString());\n return field.defaultValue === undefined\n ? typeReference\n : [typeReference, field.defaultValue];\n}\n\nfunction encodeFieldDef(\n field: GraphQLField<unknown, unknown>,\n argumentsFilter?: (arg: GraphQLArgument) => boolean,\n): FieldDefinition {\n const typeReference = typeReferenceFromName(field.type.toString());\n const [hasArgs, argsRecord] = encodeArguments(field.args, argumentsFilter);\n return !hasArgs ? typeReference : [typeReference, argsRecord];\n}\n\nfunction encodeArguments(\n args: ReadonlyArray<GraphQLArgument>,\n argumentsFilter?: (arg: GraphQLArgument) => boolean,\n): [boolean, InputValueDefinitionRecord] {\n let hasArgs = false;\n const argsRecord: InputValueDefinitionRecord = {};\n for (const argDef of args) {\n if (argumentsFilter && !argumentsFilter(argDef)) {\n continue;\n }\n const typeReference = typeReferenceFromName(argDef.type.toString());\n argsRecord[argDef.name] =\n argDef.defaultValue === undefined\n ? typeReference\n : [typeReference, argDef.defaultValue];\n hasArgs = true;\n }\n return [hasArgs, argsRecord];\n}\n\nfunction encodeEnumType(type: GraphQLEnumType): EnumTypeDefinitionTuple {\n return createEnumTypeDefinition(type.getValues().map((v) => v.name));\n}\n\nfunction encodeScalarType(_type: GraphQLScalarType): ScalarTypeDefinitionTuple {\n return createScalarTypeDefinition();\n}\n\nfunction assertCompositeType(\n type: Maybe<GraphQLOutputType>,\n node: ASTNode,\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n): asserts type is GraphQLCompositeType {\n if (!type || !isCompositeType(type)) {\n const path =\n node.kind === Kind.FIELD\n ? makeReadableErrorPath(ancestors).join(\".\") + \".\" + node.name.value\n : makeReadableErrorPath(ancestors).join(\".\");\n throw locatedError(`Cannot find type for: ${path}`, [node]);\n }\n}\n\nfunction assertExistingField(\n field: Maybe<GraphQLField<unknown, unknown>>,\n node: FieldNode,\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n): asserts field is GraphQLField<unknown, unknown> {\n if (!field) {\n const path =\n makeReadableErrorPath(ancestors).join(\".\") + \".\" + node.name.value;\n throw locatedError(`Cannot find field: ${path}`, [node]);\n }\n}\n\nfunction assertAllArgumentsAreDefined(\n field: GraphQLField<unknown, unknown> | GraphQLDirective,\n node: FieldNode | DirectiveNode,\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n) {\n const defArgs = new Set(field.args.map((arg) => arg.name));\n for (const arg of node.arguments ?? []) {\n if (!defArgs.has(arg.name.value)) {\n const path =\n makeReadableErrorPath(ancestors).join(\".\") +\n \".\" +\n node.name.value +\n `(${arg.name.value}: ...)`;\n throw locatedError(`Cannot find type for argument: ${path}`, [arg]);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EAeE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAKA;AAAA,EAIA;AAAA,OAEK;AACP,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,i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