@graphitation/supermassive 3.13.0 → 3.14.1
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 +28 -1
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js.map +2 -2
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs +30 -2
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs.map +2 -2
- package/lib/utilities/mergeSchemaDefinitions.d.ts.map +1 -1
- package/lib/utilities/mergeSchemaDefinitions.js +17 -0
- package/lib/utilities/mergeSchemaDefinitions.js.map +2 -2
- package/lib/utilities/mergeSchemaDefinitions.mjs +17 -0
- package/lib/utilities/mergeSchemaDefinitions.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 Tue, 06 Jan 2026 13:25:38 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.14.1
|
|
8
|
+
|
|
9
|
+
Tue, 06 Jan 2026 13:25:38 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- mergeSchemaDefinitions doesn't lose implementation + basic tests added (77059398+vejrj@users.noreply.github.com)
|
|
14
|
+
|
|
15
|
+
## 3.14.0
|
|
16
|
+
|
|
17
|
+
Mon, 05 Jan 2026 11:02:15 GMT
|
|
18
|
+
|
|
19
|
+
### Minor changes
|
|
20
|
+
|
|
21
|
+
- extractMinimalViableSchemaForRequestDocument include interface implementations (77059398+vejrj@users.noreply.github.com)
|
|
22
|
+
|
|
7
23
|
## 3.13.0
|
|
8
24
|
|
|
9
|
-
Mon, 08 Dec 2025 16:15:
|
|
25
|
+
Mon, 08 Dec 2025 16:15:56 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,
|
|
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,
|
|
@@ -49,6 +50,18 @@ function extractMinimalViableSchemaForRequestDocument(schema, requestDocument) {
|
|
|
49
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)) {
|
|
@@ -65,12 +78,18 @@ function extractMinimalViableSchemaForRequestDocument(schema, requestDocument) {
|
|
|
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,6 +161,14 @@ function addCompositeType(types, type) {
|
|
|
142
161
|
}
|
|
143
162
|
return types[type.name] = encodeCompositeType(type);
|
|
144
163
|
}
|
|
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
|
+
}
|
|
145
172
|
function addField(type, field) {
|
|
146
173
|
const fields = (0, import_definition.getFields)(type);
|
|
147
174
|
return fields[field.name] = encodeFieldDef(field);
|
|
@@ -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 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 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);\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);\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): 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,
|
|
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,QAA+B,CAAC;AACtC,QAAM,aAAyC,CAAC;AAChD,QAAM,oBAAqC,CAAC;AAC5C,QAAM,kBAA4B,CAAC;AAEnC,QAAM,qCACJ,mCAAS,sCAAqC;AAEhD,QAAM,WAAW,IAAI,wBAAS,MAAM;AACpC;AAAA,IACE;AAAA,QACA,kCAAkB,UAAU;AAAA,MAC1B,MAAM,MAAM,MAAM,SAAS,OAAO,WAAiB;AACjD,cAAM,aAAa,SAAS,cAAc;AAC1C,4BAAoB,YAAY,MAAM,SAAS;AAE/C,cAAM,UAAU,iBAAiB,OAAO,UAAU;AAClD,gBACE,yCAAsB,OAAO,KAC7B,KAAK,KAAK,UAAU,cACpB;AACA;AAAA,QACF;AACA,cAAM,QAAQ,SAAS,YAAY;AACnC,4BAAoB,OAAO,MAAM,SAAS;AAC1C,qCAA6B,OAAO,MAAM,SAAS;AAEnD,cAAM,WAAW,SAAS,SAAS,KAAK;AACxC,gCAAwB,QAAQ,WAAO,yCAAsB,QAAQ,CAAC;AACtE,gCAAwB,Q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AO,8CAA2B;AACpC;AAEA,SAAS,oBACP,MACA,MACA,WACsC;AACtC,MAAI,CAAC,QAAQ,KAAC,gCAAgB,IAAI,GAAG;AACnC,UAAM,OACJ,KAAK,SAAS,oBAAK,YACf,oDAAsB,SAAS,EAAE,KAAK,GAAG,IAAI,MAAM,KAAK,KAAK,YAC7D,oDAAsB,SAAS,EAAE,KAAK,GAAG;AAC/C,cAAM,6BAAa,yBAAyB,QAAQ,CAAC,IAAI,CAAC;AAAA,EAC5D;AACF;AAEA,SAAS,oBACP,OACA,MACA,WACiD;AACjD,MAAI,CAAC,OAAO;AACV,UAAM,WACJ,oDAAsB,SAAS,EAAE,KAAK,GAAG,IAAI,MAAM,KAAK,KAAK;AAC/D,cAAM,6BAAa,sBAAsB,QAAQ,CAAC,IAAI,CAAC;AAAA,EACzD;AACF;AAEA,SAAS,6BACP,OACA,MACA,WACA;AAnYF;AAoYE,QAAM,UAAU,IAAI,IAAI,MAAM,KAAK,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
|
}
|
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
TypeInfo,
|
|
12
12
|
visit,
|
|
13
13
|
visitWithTypeInfo,
|
|
14
|
-
locatedError
|
|
14
|
+
locatedError,
|
|
15
|
+
isInterfaceType
|
|
15
16
|
} from "graphql";
|
|
16
17
|
import {
|
|
17
18
|
createEnumTypeDefinition,
|
|
@@ -38,11 +39,12 @@ import {
|
|
|
38
39
|
typeReferenceFromName
|
|
39
40
|
} from "../schema/reference.mjs";
|
|
40
41
|
import { invariant } from "../jsutils/invariant.mjs";
|
|
41
|
-
function extractMinimalViableSchemaForRequestDocument(schema, requestDocument) {
|
|
42
|
+
function extractMinimalViableSchemaForRequestDocument(schema, requestDocument, options) {
|
|
42
43
|
const types = {};
|
|
43
44
|
const directives = [];
|
|
44
45
|
const unknownDirectives = [];
|
|
45
46
|
const fragmentSpreads = [];
|
|
47
|
+
const includeInterfaceImplementingTypes = (options == null ? void 0 : options.includeInterfaceImplementingTypes) || false;
|
|
46
48
|
const typeInfo = new TypeInfo(schema);
|
|
47
49
|
visit(
|
|
48
50
|
requestDocument,
|
|
@@ -60,6 +62,18 @@ function extractMinimalViableSchemaForRequestDocument(schema, requestDocument) {
|
|
|
60
62
|
const fieldDef = addField(typeDef, field);
|
|
61
63
|
addReferencedOutputType(schema, types, getFieldTypeReference(fieldDef));
|
|
62
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
|
+
}
|
|
63
77
|
},
|
|
64
78
|
Directive(node, _key, _parent, _path) {
|
|
65
79
|
if (isKnownDirective(node.name.value)) {
|
|
@@ -76,12 +90,18 @@ function extractMinimalViableSchemaForRequestDocument(schema, requestDocument) {
|
|
|
76
90
|
const type = typeInfo.getType();
|
|
77
91
|
assertCompositeType(type, node, ancestors);
|
|
78
92
|
addCompositeType(types, type);
|
|
93
|
+
if (includeInterfaceImplementingTypes) {
|
|
94
|
+
addImplementingTypes(schema, types, type);
|
|
95
|
+
}
|
|
79
96
|
},
|
|
80
97
|
InlineFragment(node, _key, _parent, _path, ancestors) {
|
|
81
98
|
if (node == null ? void 0 : node.typeCondition) {
|
|
82
99
|
const type = typeInfo.getType();
|
|
83
100
|
assertCompositeType(type, node, ancestors);
|
|
84
101
|
addCompositeType(types, type);
|
|
102
|
+
if (includeInterfaceImplementingTypes) {
|
|
103
|
+
addImplementingTypes(schema, types, type);
|
|
104
|
+
}
|
|
85
105
|
}
|
|
86
106
|
},
|
|
87
107
|
FragmentSpread(node) {
|
|
@@ -153,6 +173,14 @@ function addCompositeType(types, type) {
|
|
|
153
173
|
}
|
|
154
174
|
return types[type.name] = encodeCompositeType(type);
|
|
155
175
|
}
|
|
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
|
+
}
|
|
156
184
|
function addField(type, field) {
|
|
157
185
|
const fields = getFields(type);
|
|
158
186
|
return fields[field.name] = encodeFieldDef(field);
|
|
@@ -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 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 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);\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);\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): 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,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,iBAAiB;
|
|
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,iBAAiB;AAanB,SAAS,6CACd,QACA,iBACA,SACkC;AAClC,QAAM,QAA+B,CAAC;AACtC,QAAM,aAAyC,CAAC;AAChD,QAAM,oBAAqC,CAAC;AAC5C,QAAM,kBAA4B,CAAC;AAEnC,QAAM,qCACJ,mCAAS,sCAAqC;AAEhD,QAAM,WAAW,IAAI,SAAS,MAAM;AACpC;AAAA,IACE;AAAA,IACA,kBAAkB,UAAU;AAAA,MAC1B,MAAM,MAAM,MAAM,SAAS,OAAO,WAAiB;AACjD,cAAM,aAAa,SAAS,cAAc;AAC1C,4BAAoB,YAAY,MAAM,SAAS;AAE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|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeSchemaDefinitions.d.ts","sourceRoot":"","sources":["../../src/utilities/mergeSchemaDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,
|
|
1
|
+
{"version":3,"file":"mergeSchemaDefinitions.d.ts","sourceRoot":"","sources":["../../src/utilities/mergeSchemaDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EAaxB,iBAAiB,EAGjB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAG9B,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,iBAAiB,EAAE,qBAEvE;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,iBAAiB,EAC9B,WAAW,EAAE,iBAAiB,EAAE,GAC/B,iBAAiB,CAiBnB;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,wBAAwB,EAAE,EAClC,MAAM,EAAE,wBAAwB,EAAE,QAsBnC;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,qBAAqB,GAC5B,IAAI,CAqCN"}
|
|
@@ -78,6 +78,7 @@ function mergeTypes(target, source) {
|
|
|
78
78
|
}
|
|
79
79
|
if ((0, import_definition.isObjectTypeDefinition)(targetDef) && (0, import_definition.isObjectTypeDefinition)(sourceDef) || (0, import_definition.isInterfaceTypeDefinition)(targetDef) && (0, import_definition.isInterfaceTypeDefinition)(sourceDef)) {
|
|
80
80
|
mergeFields((0, import_definition.getFields)(targetDef), (0, import_definition.getFields)(sourceDef));
|
|
81
|
+
mergeInterfaces(targetDef, sourceDef);
|
|
81
82
|
continue;
|
|
82
83
|
}
|
|
83
84
|
if ((0, import_definition.isInputObjectTypeDefinition)(targetDef) && (0, import_definition.isInputObjectTypeDefinition)(sourceDef)) {
|
|
@@ -111,6 +112,22 @@ function mergeFields(target, source) {
|
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
}
|
|
115
|
+
function mergeInterfaces(target, source) {
|
|
116
|
+
const targetInterfaces = target[2];
|
|
117
|
+
const sourceInterfaces = source[2];
|
|
118
|
+
if (!sourceInterfaces) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (!targetInterfaces) {
|
|
122
|
+
target[2] = [...sourceInterfaces];
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
for (const interfaceName of sourceInterfaces) {
|
|
126
|
+
if (!targetInterfaces.includes(interfaceName)) {
|
|
127
|
+
targetInterfaces.push(interfaceName);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
114
131
|
function mergeInputValues(target, source) {
|
|
115
132
|
for (const [fieldName, sourceDef] of Object.entries(source)) {
|
|
116
133
|
const targetDef = target[fieldName];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utilities/mergeSchemaDefinitions.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n DirectiveDefinitionTuple,\n FieldDefinitionRecord,\n getDirectiveDefinitionArgs,\n getDirectiveName,\n getFieldArgs,\n getFields,\n getInputObjectFields,\n InputValueDefinitionRecord,\n isInputObjectTypeDefinition,\n isInterfaceTypeDefinition,\n isObjectTypeDefinition,\n SchemaDefinitions,\n setDirectiveDefinitionArgs,\n setFieldArgs,\n TypeDefinitionsRecord,\n} from \"../schema/definition\";\nimport { inspect } from \"../jsutils/inspect\";\n\nexport function createSchemaDefinitions(definitions: SchemaDefinitions[]) {\n return mergeSchemaDefinitions({ types: {}, directives: [] }, definitions);\n}\n\nexport function mergeSchemaDefinitions(\n accumulator: SchemaDefinitions,\n definitions: SchemaDefinitions[],\n): SchemaDefinitions {\n if (!definitions.length) {\n return accumulator;\n }\n for (const source of definitions) {\n if (!accumulator.types) {\n accumulator.types = source.types;\n } else if (source.types) {\n mergeTypes(accumulator.types, source.types);\n }\n if (!accumulator.directives) {\n accumulator.directives = source.directives;\n } else if (source.directives?.length) {\n mergeDirectives(accumulator.directives, source.directives);\n }\n }\n return accumulator;\n}\n\nexport function mergeDirectives(\n target: DirectiveDefinitionTuple[],\n source: DirectiveDefinitionTuple[],\n) {\n for (const sourceDirective of source) {\n const targetDirective = target.find(\n (directive) =>\n getDirectiveName(directive) === getDirectiveName(sourceDirective),\n );\n if (!targetDirective) {\n target.push(sourceDirective);\n continue;\n }\n const sourceArgs = getDirectiveDefinitionArgs(sourceDirective);\n if (!sourceArgs) {\n continue;\n }\n const targetArgs = getDirectiveDefinitionArgs(targetDirective);\n if (!targetArgs) {\n setDirectiveDefinitionArgs(targetDirective, sourceArgs);\n continue;\n }\n mergeInputValues(targetArgs, sourceArgs);\n }\n}\n\n/**\n * Adds missing definitions from source into target. Mutates target in place.\n */\nexport function mergeTypes(\n target: TypeDefinitionsRecord,\n source: TypeDefinitionsRecord,\n): void {\n for (const [typeName, sourceDef] of Object.entries(source)) {\n const targetDef = target[typeName];\n if (!targetDef) {\n target[typeName] = sourceDef;\n continue;\n }\n if (\n (isObjectTypeDefinition(targetDef) &&\n isObjectTypeDefinition(sourceDef)) ||\n (isInterfaceTypeDefinition(targetDef) &&\n isInterfaceTypeDefinition(sourceDef))\n ) {\n mergeFields(getFields(targetDef), getFields(sourceDef));\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import {\n DirectiveDefinitionTuple,\n FieldDefinitionRecord,\n getDirectiveDefinitionArgs,\n getDirectiveName,\n getFieldArgs,\n getFields,\n getInputObjectFields,\n InputValueDefinitionRecord,\n InterfaceTypeDefinitionTuple,\n isInputObjectTypeDefinition,\n isInterfaceTypeDefinition,\n isObjectTypeDefinition,\n ObjectTypeDefinitionTuple,\n SchemaDefinitions,\n setDirectiveDefinitionArgs,\n setFieldArgs,\n TypeDefinitionsRecord,\n} from \"../schema/definition\";\nimport { inspect } from \"../jsutils/inspect\";\n\nexport function createSchemaDefinitions(definitions: SchemaDefinitions[]) {\n return mergeSchemaDefinitions({ types: {}, directives: [] }, definitions);\n}\n\nexport function mergeSchemaDefinitions(\n accumulator: SchemaDefinitions,\n definitions: SchemaDefinitions[],\n): SchemaDefinitions {\n if (!definitions.length) {\n return accumulator;\n }\n for (const source of definitions) {\n if (!accumulator.types) {\n accumulator.types = source.types;\n } else if (source.types) {\n mergeTypes(accumulator.types, source.types);\n }\n if (!accumulator.directives) {\n accumulator.directives = source.directives;\n } else if (source.directives?.length) {\n mergeDirectives(accumulator.directives, source.directives);\n }\n }\n return accumulator;\n}\n\nexport function mergeDirectives(\n target: DirectiveDefinitionTuple[],\n source: DirectiveDefinitionTuple[],\n) {\n for (const sourceDirective of source) {\n const targetDirective = target.find(\n (directive) =>\n getDirectiveName(directive) === getDirectiveName(sourceDirective),\n );\n if (!targetDirective) {\n target.push(sourceDirective);\n continue;\n }\n const sourceArgs = getDirectiveDefinitionArgs(sourceDirective);\n if (!sourceArgs) {\n continue;\n }\n const targetArgs = getDirectiveDefinitionArgs(targetDirective);\n if (!targetArgs) {\n setDirectiveDefinitionArgs(targetDirective, sourceArgs);\n continue;\n }\n mergeInputValues(targetArgs, sourceArgs);\n }\n}\n\n/**\n * Adds missing definitions from source into target. Mutates target in place.\n */\nexport function mergeTypes(\n target: TypeDefinitionsRecord,\n source: TypeDefinitionsRecord,\n): void {\n for (const [typeName, sourceDef] of Object.entries(source)) {\n const targetDef = target[typeName];\n if (!targetDef) {\n target[typeName] = sourceDef;\n continue;\n }\n if (\n (isObjectTypeDefinition(targetDef) &&\n isObjectTypeDefinition(sourceDef)) ||\n (isInterfaceTypeDefinition(targetDef) &&\n isInterfaceTypeDefinition(sourceDef))\n ) {\n mergeFields(getFields(targetDef), getFields(sourceDef));\n mergeInterfaces(targetDef, sourceDef);\n continue;\n }\n if (\n isInputObjectTypeDefinition(targetDef) &&\n isInputObjectTypeDefinition(sourceDef)\n ) {\n mergeInputValues(\n getInputObjectFields(targetDef),\n getInputObjectFields(sourceDef),\n );\n continue;\n }\n // Note: not merging scalars, unions and enums - assuming they are fully defined by the first occurrence\n if (targetDef[0] !== sourceDef[0]) {\n throw new Error(\n `Type ${typeName} is represented differently in different schema fragments:\\n` +\n inspect(targetDef) +\n `\\n` +\n inspect(sourceDef),\n );\n }\n }\n}\n\nfunction mergeFields(\n target: FieldDefinitionRecord,\n source: FieldDefinitionRecord,\n) {\n for (const [fieldName, sourceDef] of Object.entries(source)) {\n const targetDef = target[fieldName];\n if (!target[fieldName] || !Array.isArray(targetDef)) {\n target[fieldName] = sourceDef;\n continue;\n }\n const sourceArgs = getFieldArgs(sourceDef);\n if (sourceArgs) {\n const targetArgs = getFieldArgs(targetDef) ?? setFieldArgs(targetDef, {});\n mergeInputValues(targetArgs, sourceArgs);\n }\n }\n}\n\nfunction mergeInterfaces(\n target: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n source: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n): void {\n const targetInterfaces = target[2];\n const sourceInterfaces = source[2];\n\n if (!sourceInterfaces) {\n return;\n }\n\n if (!targetInterfaces) {\n target[2] = [...sourceInterfaces];\n return;\n }\n\n for (const interfaceName of sourceInterfaces) {\n if (!targetInterfaces.includes(interfaceName)) {\n targetInterfaces.push(interfaceName);\n }\n }\n}\n\nfunction mergeInputValues(\n target: InputValueDefinitionRecord,\n source: InputValueDefinitionRecord,\n) {\n for (const [fieldName, sourceDef] of Object.entries(source)) {\n const targetDef = target[fieldName];\n if (!target[fieldName] || !Array.isArray(targetDef)) {\n target[fieldName] = sourceDef;\n }\n // Note: not merging defaultValue - assuming it is fully defined by the first occurrence\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAkBO;AACP,qBAAwB;AAEjB,SAAS,wBAAwB,aAAkC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K,OAAO,QAAQ,MAAM,GAAG;AAC3D,UAAM,YAAY,OAAO,SAAS;AAClC,QAAI,CAAC,OAAO,SAAS,KAAK,CAAC,MAAM,QAAQ,SAAS,GAAG;AACnD,aAAO,SAAS,IAAI;AAAA,IACtB;AAAA,EAEF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -64,6 +64,7 @@ function mergeTypes(target, source) {
|
|
|
64
64
|
}
|
|
65
65
|
if (isObjectTypeDefinition(targetDef) && isObjectTypeDefinition(sourceDef) || isInterfaceTypeDefinition(targetDef) && isInterfaceTypeDefinition(sourceDef)) {
|
|
66
66
|
mergeFields(getFields(targetDef), getFields(sourceDef));
|
|
67
|
+
mergeInterfaces(targetDef, sourceDef);
|
|
67
68
|
continue;
|
|
68
69
|
}
|
|
69
70
|
if (isInputObjectTypeDefinition(targetDef) && isInputObjectTypeDefinition(sourceDef)) {
|
|
@@ -97,6 +98,22 @@ function mergeFields(target, source) {
|
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
}
|
|
101
|
+
function mergeInterfaces(target, source) {
|
|
102
|
+
const targetInterfaces = target[2];
|
|
103
|
+
const sourceInterfaces = source[2];
|
|
104
|
+
if (!sourceInterfaces) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (!targetInterfaces) {
|
|
108
|
+
target[2] = [...sourceInterfaces];
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
for (const interfaceName of sourceInterfaces) {
|
|
112
|
+
if (!targetInterfaces.includes(interfaceName)) {
|
|
113
|
+
targetInterfaces.push(interfaceName);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
100
117
|
function mergeInputValues(target, source) {
|
|
101
118
|
for (const [fieldName, sourceDef] of Object.entries(source)) {
|
|
102
119
|
const targetDef = target[fieldName];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utilities/mergeSchemaDefinitions.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n DirectiveDefinitionTuple,\n FieldDefinitionRecord,\n getDirectiveDefinitionArgs,\n getDirectiveName,\n getFieldArgs,\n getFields,\n getInputObjectFields,\n InputValueDefinitionRecord,\n isInputObjectTypeDefinition,\n isInterfaceTypeDefinition,\n isObjectTypeDefinition,\n SchemaDefinitions,\n setDirectiveDefinitionArgs,\n setFieldArgs,\n TypeDefinitionsRecord,\n} from \"../schema/definition\";\nimport { inspect } from \"../jsutils/inspect\";\n\nexport function createSchemaDefinitions(definitions: SchemaDefinitions[]) {\n return mergeSchemaDefinitions({ types: {}, directives: [] }, definitions);\n}\n\nexport function mergeSchemaDefinitions(\n accumulator: SchemaDefinitions,\n definitions: SchemaDefinitions[],\n): SchemaDefinitions {\n if (!definitions.length) {\n return accumulator;\n }\n for (const source of definitions) {\n if (!accumulator.types) {\n accumulator.types = source.types;\n } else if (source.types) {\n mergeTypes(accumulator.types, source.types);\n }\n if (!accumulator.directives) {\n accumulator.directives = source.directives;\n } else if (source.directives?.length) {\n mergeDirectives(accumulator.directives, source.directives);\n }\n }\n return accumulator;\n}\n\nexport function mergeDirectives(\n target: DirectiveDefinitionTuple[],\n source: DirectiveDefinitionTuple[],\n) {\n for (const sourceDirective of source) {\n const targetDirective = target.find(\n (directive) =>\n getDirectiveName(directive) === getDirectiveName(sourceDirective),\n );\n if (!targetDirective) {\n target.push(sourceDirective);\n continue;\n }\n const sourceArgs = getDirectiveDefinitionArgs(sourceDirective);\n if (!sourceArgs) {\n continue;\n }\n const targetArgs = getDirectiveDefinitionArgs(targetDirective);\n if (!targetArgs) {\n setDirectiveDefinitionArgs(targetDirective, sourceArgs);\n continue;\n }\n mergeInputValues(targetArgs, sourceArgs);\n }\n}\n\n/**\n * Adds missing definitions from source into target. Mutates target in place.\n */\nexport function mergeTypes(\n target: TypeDefinitionsRecord,\n source: TypeDefinitionsRecord,\n): void {\n for (const [typeName, sourceDef] of Object.entries(source)) {\n const targetDef = target[typeName];\n if (!targetDef) {\n target[typeName] = sourceDef;\n continue;\n }\n if (\n (isObjectTypeDefinition(targetDef) &&\n isObjectTypeDefinition(sourceDef)) ||\n (isInterfaceTypeDefinition(targetDef) &&\n isInterfaceTypeDefinition(sourceDef))\n ) {\n mergeFields(getFields(targetDef), getFields(sourceDef));\n
|
|
5
|
-
"mappings": ";AAAA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,
|
|
4
|
+
"sourcesContent": ["import {\n DirectiveDefinitionTuple,\n FieldDefinitionRecord,\n getDirectiveDefinitionArgs,\n getDirectiveName,\n getFieldArgs,\n getFields,\n getInputObjectFields,\n InputValueDefinitionRecord,\n InterfaceTypeDefinitionTuple,\n isInputObjectTypeDefinition,\n isInterfaceTypeDefinition,\n isObjectTypeDefinition,\n ObjectTypeDefinitionTuple,\n SchemaDefinitions,\n setDirectiveDefinitionArgs,\n setFieldArgs,\n TypeDefinitionsRecord,\n} from \"../schema/definition\";\nimport { inspect } from \"../jsutils/inspect\";\n\nexport function createSchemaDefinitions(definitions: SchemaDefinitions[]) {\n return mergeSchemaDefinitions({ types: {}, directives: [] }, definitions);\n}\n\nexport function mergeSchemaDefinitions(\n accumulator: SchemaDefinitions,\n definitions: SchemaDefinitions[],\n): SchemaDefinitions {\n if (!definitions.length) {\n return accumulator;\n }\n for (const source of definitions) {\n if (!accumulator.types) {\n accumulator.types = source.types;\n } else if (source.types) {\n mergeTypes(accumulator.types, source.types);\n }\n if (!accumulator.directives) {\n accumulator.directives = source.directives;\n } else if (source.directives?.length) {\n mergeDirectives(accumulator.directives, source.directives);\n }\n }\n return accumulator;\n}\n\nexport function mergeDirectives(\n target: DirectiveDefinitionTuple[],\n source: DirectiveDefinitionTuple[],\n) {\n for (const sourceDirective of source) {\n const targetDirective = target.find(\n (directive) =>\n getDirectiveName(directive) === getDirectiveName(sourceDirective),\n );\n if (!targetDirective) {\n target.push(sourceDirective);\n continue;\n }\n const sourceArgs = getDirectiveDefinitionArgs(sourceDirective);\n if (!sourceArgs) {\n continue;\n }\n const targetArgs = getDirectiveDefinitionArgs(targetDirective);\n if (!targetArgs) {\n setDirectiveDefinitionArgs(targetDirective, sourceArgs);\n continue;\n }\n mergeInputValues(targetArgs, sourceArgs);\n }\n}\n\n/**\n * Adds missing definitions from source into target. Mutates target in place.\n */\nexport function mergeTypes(\n target: TypeDefinitionsRecord,\n source: TypeDefinitionsRecord,\n): void {\n for (const [typeName, sourceDef] of Object.entries(source)) {\n const targetDef = target[typeName];\n if (!targetDef) {\n target[typeName] = sourceDef;\n continue;\n }\n if (\n (isObjectTypeDefinition(targetDef) &&\n isObjectTypeDefinition(sourceDef)) ||\n (isInterfaceTypeDefinition(targetDef) &&\n isInterfaceTypeDefinition(sourceDef))\n ) {\n mergeFields(getFields(targetDef), getFields(sourceDef));\n mergeInterfaces(targetDef, sourceDef);\n continue;\n }\n if (\n isInputObjectTypeDefinition(targetDef) &&\n isInputObjectTypeDefinition(sourceDef)\n ) {\n mergeInputValues(\n getInputObjectFields(targetDef),\n getInputObjectFields(sourceDef),\n );\n continue;\n }\n // Note: not merging scalars, unions and enums - assuming they are fully defined by the first occurrence\n if (targetDef[0] !== sourceDef[0]) {\n throw new Error(\n `Type ${typeName} is represented differently in different schema fragments:\\n` +\n inspect(targetDef) +\n `\\n` +\n inspect(sourceDef),\n );\n }\n }\n}\n\nfunction mergeFields(\n target: FieldDefinitionRecord,\n source: FieldDefinitionRecord,\n) {\n for (const [fieldName, sourceDef] of Object.entries(source)) {\n const targetDef = target[fieldName];\n if (!target[fieldName] || !Array.isArray(targetDef)) {\n target[fieldName] = sourceDef;\n continue;\n }\n const sourceArgs = getFieldArgs(sourceDef);\n if (sourceArgs) {\n const targetArgs = getFieldArgs(targetDef) ?? setFieldArgs(targetDef, {});\n mergeInputValues(targetArgs, sourceArgs);\n }\n }\n}\n\nfunction mergeInterfaces(\n target: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n source: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n): void {\n const targetInterfaces = target[2];\n const sourceInterfaces = source[2];\n\n if (!sourceInterfaces) {\n return;\n }\n\n if (!targetInterfaces) {\n target[2] = [...sourceInterfaces];\n return;\n }\n\n for (const interfaceName of sourceInterfaces) {\n if (!targetInterfaces.includes(interfaceName)) {\n targetInterfaces.push(interfaceName);\n }\n }\n}\n\nfunction mergeInputValues(\n target: InputValueDefinitionRecord,\n source: InputValueDefinitionRecord,\n) {\n for (const [fieldName, sourceDef] of Object.entries(source)) {\n const targetDef = target[fieldName];\n if (!target[fieldName] || !Array.isArray(targetDef)) {\n target[fieldName] = sourceDef;\n }\n // Note: not merging defaultValue - assuming it is fully defined by the first occurrence\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,eAAe;AAEjB,SAAS,wBAAwB,aAAkC;AACxE,SAAO,uBAAuB,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,EAAE,GAAG,WAAW;AAC1E;AAEO,SAAS,uBACd,aACA,aACmB;AA5BrB;AA6BE,MAAI,CAAC,YAAY,QAAQ;AACvB,WAAO;AAAA,EACT;AACA,aAAW,UAAU,aAAa;AAChC,QAAI,CAAC,YAAY,OAAO;AACtB,kBAAY,QAAQ,OAAO;AAAA,IAC7B,WAAW,OAAO,OAAO;AACvB,iBAAW,YAAY,OAAO,OAAO,KAAK;AAAA,IAC5C;AACA,QAAI,CAAC,YAAY,YAAY;AAC3B,kBAAY,aAAa,OAAO;AAAA,IAClC,YAAW,YAAO,eAAP,mBAAmB,QAAQ;AACpC,sBAAgB,YAAY,YAAY,OAAO,UAAU;AAAA,IAC3D;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,gBACd,QACA,QACA;AACA,aAAW,m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