@graphitation/supermassive 2.6.1 → 3.0.0-alpha.3
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 +17 -1
- package/lib/__testUtils__/execute.d.ts +13 -0
- package/lib/__testUtils__/execute.d.ts.map +1 -0
- package/lib/__testUtils__/execute.js +196 -0
- package/lib/__testUtils__/execute.js.map +7 -0
- package/lib/__testUtils__/execute.mjs +174 -0
- package/lib/__testUtils__/execute.mjs.map +7 -0
- package/lib/benchmarks/index.js +11 -20
- package/lib/benchmarks/index.js.map +3 -3
- package/lib/benchmarks/index.mjs +12 -23
- package/lib/benchmarks/index.mjs.map +2 -2
- package/lib/benchmarks/swapi-schema/index.d.ts +4 -2
- package/lib/benchmarks/swapi-schema/index.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/index.js +8 -2
- package/lib/benchmarks/swapi-schema/index.js.map +2 -2
- package/lib/benchmarks/swapi-schema/index.mjs +8 -2
- package/lib/benchmarks/swapi-schema/index.mjs.map +2 -2
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.d.ts +7 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.d.ts.map +1 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.js +916 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.js.map +7 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.mjs +903 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.mjs.map +7 -0
- package/lib/benchmarks/swapi-schema/resolvers.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/resolvers.js +53 -17
- package/lib/benchmarks/swapi-schema/resolvers.js.map +2 -2
- package/lib/benchmarks/swapi-schema/resolvers.mjs +54 -18
- package/lib/benchmarks/swapi-schema/resolvers.mjs.map +2 -2
- package/lib/collectFields.d.ts +27 -10
- package/lib/collectFields.d.ts.map +1 -1
- package/lib/collectFields.js +146 -80
- package/lib/collectFields.js.map +3 -3
- package/lib/collectFields.mjs +143 -81
- package/lib/collectFields.mjs.map +2 -2
- package/lib/executeWithSchema.d.ts +1 -1
- package/lib/executeWithSchema.d.ts.map +1 -1
- package/lib/executeWithSchema.js +7 -13
- package/lib/executeWithSchema.js.map +2 -2
- package/lib/executeWithSchema.mjs +9 -20
- package/lib/executeWithSchema.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +53 -16
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +1076 -274
- package/lib/executeWithoutSchema.js.map +3 -3
- package/lib/executeWithoutSchema.mjs +1092 -281
- package/lib/executeWithoutSchema.mjs.map +3 -3
- package/lib/index.d.ts +3 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -7
- package/lib/index.js.map +2 -2
- package/lib/index.mjs +3 -10
- package/lib/index.mjs.map +2 -2
- package/lib/jsutils/AccumulatorMap.d.ts +8 -0
- package/lib/jsutils/AccumulatorMap.d.ts.map +1 -0
- package/lib/jsutils/AccumulatorMap.js +36 -0
- package/lib/jsutils/AccumulatorMap.js.map +7 -0
- package/lib/jsutils/AccumulatorMap.mjs +17 -0
- package/lib/jsutils/AccumulatorMap.mjs.map +7 -0
- package/lib/jsutils/didYouMean.d.ts +1 -2
- package/lib/jsutils/didYouMean.d.ts.map +1 -1
- package/lib/jsutils/didYouMean.js.map +2 -2
- package/lib/jsutils/didYouMean.mjs.map +2 -2
- package/lib/jsutils/instanceOf.js.map +2 -2
- package/lib/jsutils/instanceOf.mjs.map +2 -2
- package/lib/schema/definition.d.ts +95 -0
- package/lib/schema/definition.d.ts.map +1 -0
- package/lib/schema/definition.js +77 -0
- package/lib/schema/definition.js.map +7 -0
- package/lib/schema/definition.mjs +58 -0
- package/lib/schema/definition.mjs.map +7 -0
- package/lib/schema/directives.d.ts +41 -0
- package/lib/schema/directives.d.ts.map +1 -0
- package/lib/schema/directives.js +82 -0
- package/lib/schema/directives.js.map +7 -0
- package/lib/schema/directives.mjs +65 -0
- package/lib/schema/directives.mjs.map +7 -0
- package/lib/schema/fragment.d.ts +41 -0
- package/lib/schema/fragment.d.ts.map +1 -0
- package/lib/schema/fragment.js +270 -0
- package/lib/schema/fragment.js.map +7 -0
- package/lib/schema/fragment.mjs +267 -0
- package/lib/schema/fragment.mjs.map +7 -0
- package/lib/schema/reference.d.ts +12 -0
- package/lib/schema/reference.d.ts.map +1 -0
- package/lib/schema/reference.js +137 -0
- package/lib/schema/reference.js.map +7 -0
- package/lib/schema/reference.mjs +118 -0
- package/lib/schema/reference.mjs.map +7 -0
- package/lib/schema/resolvers.d.ts +9 -0
- package/lib/schema/resolvers.d.ts.map +1 -0
- package/lib/schema/resolvers.js +47 -0
- package/lib/schema/resolvers.js.map +7 -0
- package/lib/schema/resolvers.mjs +35 -0
- package/lib/schema/resolvers.mjs.map +7 -0
- package/lib/subscribeWithSchema.d.ts +3 -2
- package/lib/subscribeWithSchema.d.ts.map +1 -1
- package/lib/subscribeWithSchema.js +7 -13
- package/lib/subscribeWithSchema.js.map +2 -2
- package/lib/subscribeWithSchema.mjs +9 -20
- package/lib/subscribeWithSchema.mjs.map +2 -2
- package/lib/subscribeWithoutSchema.d.ts +3 -35
- package/lib/subscribeWithoutSchema.d.ts.map +1 -1
- package/lib/subscribeWithoutSchema.js +1 -163
- package/lib/subscribeWithoutSchema.js.map +2 -2
- package/lib/subscribeWithoutSchema.mjs +2 -175
- package/lib/subscribeWithoutSchema.mjs.map +2 -2
- package/lib/types.d.ts +71 -29
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +14 -0
- package/lib/types.js.map +2 -2
- package/lib/types.mjs +11 -0
- package/lib/types.mjs.map +3 -3
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts +9 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts.map +1 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.js +303 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.js.map +7 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs +317 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs.map +7 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.d.ts +3 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.d.ts.map +1 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.js +34 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.js.map +7 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.mjs +17 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.mjs.map +7 -0
- package/lib/utilities/coerceInputValue.d.ts +10 -0
- package/lib/utilities/coerceInputValue.d.ts.map +1 -0
- package/lib/utilities/coerceInputValue.js +181 -0
- package/lib/utilities/coerceInputValue.js.map +7 -0
- package/lib/utilities/coerceInputValue.mjs +167 -0
- package/lib/utilities/coerceInputValue.mjs.map +7 -0
- package/lib/utilities/decodeASTSchema.d.ts +7 -0
- package/lib/utilities/decodeASTSchema.d.ts.map +1 -0
- package/lib/utilities/decodeASTSchema.js +243 -0
- package/lib/utilities/decodeASTSchema.js.map +7 -0
- package/lib/utilities/decodeASTSchema.mjs +242 -0
- package/lib/utilities/decodeASTSchema.mjs.map +7 -0
- package/lib/utilities/encodeASTSchema.d.ts +4 -0
- package/lib/utilities/encodeASTSchema.d.ts.map +1 -0
- package/lib/utilities/encodeASTSchema.js +122 -0
- package/lib/utilities/encodeASTSchema.js.map +7 -0
- package/lib/utilities/encodeASTSchema.mjs +105 -0
- package/lib/utilities/encodeASTSchema.mjs.map +7 -0
- package/lib/utilities/getSchemaFragment.d.ts +4 -0
- package/lib/utilities/getSchemaFragment.d.ts.map +1 -0
- package/lib/utilities/getSchemaFragment.js +38 -0
- package/lib/utilities/getSchemaFragment.js.map +7 -0
- package/lib/utilities/getSchemaFragment.mjs +22 -0
- package/lib/utilities/getSchemaFragment.mjs.map +7 -0
- package/lib/utilities/makeReadableErrorPath.d.ts +3 -0
- package/lib/utilities/makeReadableErrorPath.d.ts.map +1 -0
- package/lib/utilities/makeReadableErrorPath.js +47 -0
- package/lib/utilities/makeReadableErrorPath.js.map +7 -0
- package/lib/utilities/makeReadableErrorPath.mjs +28 -0
- package/lib/utilities/makeReadableErrorPath.mjs.map +7 -0
- package/lib/utilities/mergeDefinitions.d.ts +8 -0
- package/lib/utilities/mergeDefinitions.d.ts.map +1 -0
- package/lib/utilities/mergeDefinitions.js +126 -0
- package/lib/utilities/mergeDefinitions.js.map +7 -0
- package/lib/utilities/mergeDefinitions.mjs +114 -0
- package/lib/utilities/mergeDefinitions.mjs.map +7 -0
- package/lib/utilities/mergeResolvers.d.ts +1 -1
- package/lib/utilities/mergeResolvers.d.ts.map +1 -1
- package/lib/utilities/mergeResolvers.js.map +2 -2
- package/lib/utilities/mergeResolvers.mjs.map +2 -2
- package/lib/utilities/typeNameFromAST.d.ts +1 -1
- package/lib/utilities/typeNameFromAST.d.ts.map +1 -1
- package/lib/utilities/typeNameFromAST.js.map +2 -2
- package/lib/utilities/typeNameFromAST.mjs.map +2 -2
- package/lib/utilities/valueFromAST.d.ts +27 -0
- package/lib/utilities/valueFromAST.d.ts.map +1 -0
- package/lib/utilities/valueFromAST.js +139 -0
- package/lib/utilities/valueFromAST.js.map +7 -0
- package/lib/utilities/valueFromAST.mjs +125 -0
- package/lib/utilities/valueFromAST.mjs.map +7 -0
- package/lib/utilities/valueFromASTUntyped.d.ts +21 -0
- package/lib/utilities/valueFromASTUntyped.d.ts.map +1 -0
- package/lib/utilities/valueFromASTUntyped.js +51 -0
- package/lib/utilities/valueFromASTUntyped.js.map +7 -0
- package/lib/utilities/valueFromASTUntyped.mjs +32 -0
- package/lib/utilities/valueFromASTUntyped.mjs.map +7 -0
- package/lib/values.d.ts +8 -13
- package/lib/values.d.ts.map +1 -1
- package/lib/values.js +83 -75
- package/lib/values.js.map +2 -2
- package/lib/values.mjs +85 -83
- package/lib/values.mjs.map +2 -2
- package/package.json +8 -9
- package/lib/definition.d.ts +0 -7
- package/lib/definition.d.ts.map +0 -1
- package/lib/definition.js +0 -59
- package/lib/definition.js.map +0 -7
- package/lib/definition.mjs +0 -40
- package/lib/definition.mjs.map +0 -7
- package/lib/directives.d.ts +0 -79
- package/lib/directives.d.ts.map +0 -1
- package/lib/directives.js +0 -160
- package/lib/directives.js.map +0 -7
- package/lib/directives.mjs +0 -146
- package/lib/directives.mjs.map +0 -7
- package/lib/extractImplicitTypesRuntime.d.ts +0 -4
- package/lib/extractImplicitTypesRuntime.d.ts.map +0 -1
- package/lib/extractImplicitTypesRuntime.js +0 -123
- package/lib/extractImplicitTypesRuntime.js.map +0 -7
- package/lib/extractImplicitTypesRuntime.mjs +0 -114
- package/lib/extractImplicitTypesRuntime.mjs.map +0 -7
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var makeReadableErrorPath_exports = {};
|
|
20
|
+
__export(makeReadableErrorPath_exports, {
|
|
21
|
+
makeReadableErrorPath: () => makeReadableErrorPath
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(makeReadableErrorPath_exports);
|
|
24
|
+
var import_graphql = require("graphql");
|
|
25
|
+
function makeReadableErrorPath(ancestors) {
|
|
26
|
+
const path = [];
|
|
27
|
+
ancestors.forEach((ancestorOrArray) => {
|
|
28
|
+
let ancestor;
|
|
29
|
+
if (!Array.isArray(ancestorOrArray)) {
|
|
30
|
+
ancestor = ancestorOrArray;
|
|
31
|
+
if (ancestor && ancestor.kind === import_graphql.Kind.FIELD) {
|
|
32
|
+
path.push(ancestor.name.value);
|
|
33
|
+
} else if (ancestor && ancestor.kind === import_graphql.Kind.DIRECTIVE) {
|
|
34
|
+
path.push(`@${ancestor.name.value}`);
|
|
35
|
+
} else if (ancestor && ancestor.kind === import_graphql.Kind.OPERATION_DEFINITION) {
|
|
36
|
+
let name;
|
|
37
|
+
if (ancestor.name) {
|
|
38
|
+
name = `${ancestor.operation} ${ancestor.name.value}`;
|
|
39
|
+
} else {
|
|
40
|
+
name = ancestor.operation;
|
|
41
|
+
}
|
|
42
|
+
path.push(name);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return path;
|
|
47
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utilities/makeReadableErrorPath.ts"],
|
|
4
|
+
"sourcesContent": ["import { Kind, ASTNode } from \"graphql\";\n\nexport function makeReadableErrorPath(\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n): string[] {\n const path: string[] = [];\n ancestors.forEach((ancestorOrArray) => {\n let ancestor: ASTNode;\n if (!Array.isArray(ancestorOrArray)) {\n ancestor = ancestorOrArray as ASTNode;\n if (ancestor && ancestor.kind === Kind.FIELD) {\n path.push(ancestor.name.value);\n } else if (ancestor && ancestor.kind === Kind.DIRECTIVE) {\n path.push(`@${ancestor.name.value}`);\n } else if (ancestor && ancestor.kind === Kind.OPERATION_DEFINITION) {\n let name;\n if (ancestor.name) {\n name = `${ancestor.operation} ${ancestor.name.value}`;\n } else {\n name = ancestor.operation;\n }\n path.push(name);\n }\n }\n });\n return path;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA8B;AAEvB,SAAS,sBACd,WACU;AACV,QAAM,OAAiB,CAAC;AACxB,YAAU,QAAQ,CAAC,oBAAoB;AACrC,QAAI;AACJ,QAAI,CAAC,MAAM,QAAQ,eAAe,GAAG;AACnC,iBAAW;AACX,UAAI,YAAY,SAAS,SAAS,oBAAK,OAAO;AAC5C,aAAK,KAAK,SAAS,KAAK,KAAK;AAAA,MAC/B,WAAW,YAAY,SAAS,SAAS,oBAAK,WAAW;AACvD,aAAK,KAAK,IAAI,SAAS,KAAK,OAAO;AAAA,MACrC,WAAW,YAAY,SAAS,SAAS,oBAAK,sBAAsB;AAClE,YAAI;AACJ,YAAI,SAAS,MAAM;AACjB,iBAAO,GAAG,SAAS,aAAa,SAAS,KAAK;AAAA,QAChD,OAAO;AACL,iBAAO,SAAS;AAAA,QAClB;AACA,aAAK,KAAK,IAAI;AAAA,MAChB;AAAA,IACF;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/utilities/makeReadableErrorPath.ts
|
|
2
|
+
import { Kind } from "graphql";
|
|
3
|
+
function makeReadableErrorPath(ancestors) {
|
|
4
|
+
const path = [];
|
|
5
|
+
ancestors.forEach((ancestorOrArray) => {
|
|
6
|
+
let ancestor;
|
|
7
|
+
if (!Array.isArray(ancestorOrArray)) {
|
|
8
|
+
ancestor = ancestorOrArray;
|
|
9
|
+
if (ancestor && ancestor.kind === Kind.FIELD) {
|
|
10
|
+
path.push(ancestor.name.value);
|
|
11
|
+
} else if (ancestor && ancestor.kind === Kind.DIRECTIVE) {
|
|
12
|
+
path.push(`@${ancestor.name.value}`);
|
|
13
|
+
} else if (ancestor && ancestor.kind === Kind.OPERATION_DEFINITION) {
|
|
14
|
+
let name;
|
|
15
|
+
if (ancestor.name) {
|
|
16
|
+
name = `${ancestor.operation} ${ancestor.name.value}`;
|
|
17
|
+
} else {
|
|
18
|
+
name = ancestor.operation;
|
|
19
|
+
}
|
|
20
|
+
path.push(name);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return path;
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
makeReadableErrorPath
|
|
28
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utilities/makeReadableErrorPath.ts"],
|
|
4
|
+
"sourcesContent": ["import { Kind, ASTNode } from \"graphql\";\n\nexport function makeReadableErrorPath(\n ancestors: ReadonlyArray<readonly ASTNode[] | ASTNode>,\n): string[] {\n const path: string[] = [];\n ancestors.forEach((ancestorOrArray) => {\n let ancestor: ASTNode;\n if (!Array.isArray(ancestorOrArray)) {\n ancestor = ancestorOrArray as ASTNode;\n if (ancestor && ancestor.kind === Kind.FIELD) {\n path.push(ancestor.name.value);\n } else if (ancestor && ancestor.kind === Kind.DIRECTIVE) {\n path.push(`@${ancestor.name.value}`);\n } else if (ancestor && ancestor.kind === Kind.OPERATION_DEFINITION) {\n let name;\n if (ancestor.name) {\n name = `${ancestor.operation} ${ancestor.name.value}`;\n } else {\n name = ancestor.operation;\n }\n path.push(name);\n }\n }\n });\n return path;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,YAAqB;AAEvB,SAAS,sBACd,WACU;AACV,QAAM,OAAiB,CAAC;AACxB,YAAU,QAAQ,CAAC,oBAAoB;AACrC,QAAI;AACJ,QAAI,CAAC,MAAM,QAAQ,eAAe,GAAG;AACnC,iBAAW;AACX,UAAI,YAAY,SAAS,SAAS,KAAK,OAAO;AAC5C,aAAK,KAAK,SAAS,KAAK,KAAK;AAAA,MAC/B,WAAW,YAAY,SAAS,SAAS,KAAK,WAAW;AACvD,aAAK,KAAK,IAAI,SAAS,KAAK,OAAO;AAAA,MACrC,WAAW,YAAY,SAAS,SAAS,KAAK,sBAAsB;AAClE,YAAI;AACJ,YAAI,SAAS,MAAM;AACjB,iBAAO,GAAG,SAAS,aAAa,SAAS,KAAK;AAAA,QAChD,OAAO;AACL,iBAAO,SAAS;AAAA,QAClB;AACA,aAAK,KAAK,IAAI;AAAA,MAChB;AAAA,IACF;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DirectiveDefinitionTuple, SchemaFragmentDefinitions, TypeDefinitionsRecord } from "../schema/definition";
|
|
2
|
+
export declare function mergeSchemaDefinitions(target: SchemaFragmentDefinitions, sources: SchemaFragmentDefinitions[]): SchemaFragmentDefinitions | undefined;
|
|
3
|
+
export declare function mergeDirectives(target: DirectiveDefinitionTuple[], source: DirectiveDefinitionTuple[]): void;
|
|
4
|
+
/**
|
|
5
|
+
* Adds missing definitions from source into target. Mutates target in place.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mergeTypes(target: TypeDefinitionsRecord, source: TypeDefinitionsRecord): void;
|
|
8
|
+
//# sourceMappingURL=mergeDefinitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeDefinitions.d.ts","sourceRoot":"","sources":["../../src/utilities/mergeDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EAQxB,yBAAyB,EACzB,qBAAqB,EAEtB,MAAM,sBAAsB,CAAC;AAG9B,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,yBAAyB,EACjC,OAAO,EAAE,yBAAyB,EAAE,yCAiBrC;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,wBAAwB,EAAE,EAClC,MAAM,EAAE,wBAAwB,EAAE,QAuBnC;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,qBAAqB,GAC5B,IAAI,CAwCN"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var mergeDefinitions_exports = {};
|
|
20
|
+
__export(mergeDefinitions_exports, {
|
|
21
|
+
mergeDirectives: () => mergeDirectives,
|
|
22
|
+
mergeSchemaDefinitions: () => mergeSchemaDefinitions,
|
|
23
|
+
mergeTypes: () => mergeTypes
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(mergeDefinitions_exports);
|
|
26
|
+
var import_definition = require("../schema/definition");
|
|
27
|
+
var import_inspect = require("../jsutils/inspect");
|
|
28
|
+
function mergeSchemaDefinitions(target, sources) {
|
|
29
|
+
var _a;
|
|
30
|
+
if (!sources.length) {
|
|
31
|
+
return target;
|
|
32
|
+
}
|
|
33
|
+
for (const source of sources) {
|
|
34
|
+
if (!target.types) {
|
|
35
|
+
target.types = source.types;
|
|
36
|
+
} else if (source.types) {
|
|
37
|
+
mergeTypes(target.types, source.types);
|
|
38
|
+
}
|
|
39
|
+
if (!target.directives) {
|
|
40
|
+
target.directives = source.directives;
|
|
41
|
+
} else if ((_a = source.directives) == null ? void 0 : _a.length) {
|
|
42
|
+
mergeDirectives(target.directives, source.directives);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function mergeDirectives(target, source) {
|
|
47
|
+
for (const sourceDirective of source) {
|
|
48
|
+
const targetDirective = target.find(
|
|
49
|
+
(directive) => directive[import_definition.DirectiveKeys.name] === sourceDirective[import_definition.DirectiveKeys.name]
|
|
50
|
+
);
|
|
51
|
+
if (!targetDirective) {
|
|
52
|
+
target.push(sourceDirective);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (!sourceDirective[import_definition.DirectiveKeys.arguments]) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (!targetDirective[import_definition.DirectiveKeys.arguments]) {
|
|
59
|
+
targetDirective[import_definition.DirectiveKeys.arguments] = sourceDirective[import_definition.DirectiveKeys.arguments];
|
|
60
|
+
}
|
|
61
|
+
mergeInputValues(
|
|
62
|
+
targetDirective[import_definition.DirectiveKeys.arguments],
|
|
63
|
+
sourceDirective[import_definition.DirectiveKeys.arguments]
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function mergeTypes(target, source) {
|
|
68
|
+
for (const [typeName, sourceDef] of Object.entries(source)) {
|
|
69
|
+
const targetDef = target[typeName];
|
|
70
|
+
if (!targetDef) {
|
|
71
|
+
target[typeName] = sourceDef;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (targetDef[0] === import_definition.TypeKind.OBJECT && sourceDef[0] === import_definition.TypeKind.OBJECT) {
|
|
75
|
+
mergeFields(targetDef[import_definition.ObjectKeys.fields], sourceDef[import_definition.ObjectKeys.fields]);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (targetDef[0] === import_definition.TypeKind.INTERFACE && sourceDef[0] === import_definition.TypeKind.INTERFACE) {
|
|
79
|
+
mergeFields(
|
|
80
|
+
targetDef[import_definition.InterfaceKeys.fields],
|
|
81
|
+
sourceDef[import_definition.InterfaceKeys.fields]
|
|
82
|
+
);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (targetDef[0] === import_definition.TypeKind.INPUT && sourceDef[0] === import_definition.TypeKind.INPUT) {
|
|
86
|
+
mergeInputValues(
|
|
87
|
+
targetDef[import_definition.InputObjectKeys.fields],
|
|
88
|
+
sourceDef[import_definition.InputObjectKeys.fields]
|
|
89
|
+
);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (targetDef[0] !== sourceDef[0]) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
`Type ${typeName} is represented differently in different schema fragments:
|
|
95
|
+
` + (0, import_inspect.inspect)(targetDef) + `
|
|
96
|
+
` + (0, import_inspect.inspect)(sourceDef)
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function mergeFields(target, source) {
|
|
102
|
+
for (const [fieldName, sourceDef] of Object.entries(source)) {
|
|
103
|
+
const targetDef = target[fieldName];
|
|
104
|
+
if (!target[fieldName] || !Array.isArray(targetDef)) {
|
|
105
|
+
target[fieldName] = sourceDef;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (Array.isArray(sourceDef) && sourceDef[import_definition.FieldKeys.arguments]) {
|
|
109
|
+
if (!targetDef[import_definition.FieldKeys.arguments]) {
|
|
110
|
+
targetDef[import_definition.FieldKeys.arguments] = {};
|
|
111
|
+
}
|
|
112
|
+
mergeInputValues(
|
|
113
|
+
targetDef[import_definition.FieldKeys.arguments],
|
|
114
|
+
sourceDef[import_definition.FieldKeys.arguments]
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function mergeInputValues(target, source) {
|
|
120
|
+
for (const [fieldName, sourceDef] of Object.entries(source)) {
|
|
121
|
+
const targetDef = target[fieldName];
|
|
122
|
+
if (!target[fieldName] || !Array.isArray(targetDef)) {
|
|
123
|
+
target[fieldName] = sourceDef;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utilities/mergeDefinitions.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n DirectiveDefinitionTuple,\n DirectiveKeys,\n FieldDefinitionRecord,\n FieldKeys,\n InputObjectKeys,\n InputValueDefinitionRecord,\n InterfaceKeys,\n ObjectKeys,\n SchemaFragmentDefinitions,\n TypeDefinitionsRecord,\n TypeKind,\n} from \"../schema/definition\";\nimport { inspect } from \"../jsutils/inspect\";\n\nexport function mergeSchemaDefinitions(\n target: SchemaFragmentDefinitions,\n sources: SchemaFragmentDefinitions[],\n) {\n if (!sources.length) {\n return target;\n }\n for (const source of sources) {\n if (!target.types) {\n target.types = source.types;\n } else if (source.types) {\n mergeTypes(target.types, source.types);\n }\n if (!target.directives) {\n target.directives = source.directives;\n } else if (source.directives?.length) {\n mergeDirectives(target.directives, source.directives);\n }\n }\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 directive[DirectiveKeys.name] === sourceDirective[DirectiveKeys.name],\n );\n if (!targetDirective) {\n target.push(sourceDirective);\n continue;\n }\n if (!sourceDirective[DirectiveKeys.arguments]) {\n continue;\n }\n if (!targetDirective[DirectiveKeys.arguments]) {\n targetDirective[DirectiveKeys.arguments] =\n sourceDirective[DirectiveKeys.arguments];\n }\n mergeInputValues(\n targetDirective[DirectiveKeys.arguments],\n sourceDirective[DirectiveKeys.arguments],\n );\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 (targetDef[0] === TypeKind.OBJECT && sourceDef[0] === TypeKind.OBJECT) {\n mergeFields(targetDef[ObjectKeys.fields], sourceDef[ObjectKeys.fields]);\n // Note: not merging implemented interfaces - assuming they are fully defined by the first occurrence\n continue;\n }\n if (\n targetDef[0] === TypeKind.INTERFACE &&\n sourceDef[0] === TypeKind.INTERFACE\n ) {\n mergeFields(\n targetDef[InterfaceKeys.fields],\n sourceDef[InterfaceKeys.fields],\n );\n // Note: not merging implemented interfaces - assuming they are fully defined by the first occurrence\n continue;\n }\n if (targetDef[0] === TypeKind.INPUT && sourceDef[0] === TypeKind.INPUT) {\n mergeInputValues(\n targetDef[InputObjectKeys.fields],\n sourceDef[InputObjectKeys.fields],\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 if (Array.isArray(sourceDef) && sourceDef[FieldKeys.arguments]) {\n if (!targetDef[FieldKeys.arguments]) {\n targetDef[FieldKeys.arguments] = {};\n }\n mergeInputValues(\n targetDef[FieldKeys.arguments],\n sourceDef[FieldKeys.arguments],\n );\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": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// src/utilities/mergeDefinitions.ts
|
|
2
|
+
import {
|
|
3
|
+
DirectiveKeys,
|
|
4
|
+
FieldKeys,
|
|
5
|
+
InputObjectKeys,
|
|
6
|
+
InterfaceKeys,
|
|
7
|
+
ObjectKeys,
|
|
8
|
+
TypeKind
|
|
9
|
+
} from "../schema/definition.mjs";
|
|
10
|
+
import { inspect } from "../jsutils/inspect.mjs";
|
|
11
|
+
function mergeSchemaDefinitions(target, sources) {
|
|
12
|
+
var _a;
|
|
13
|
+
if (!sources.length) {
|
|
14
|
+
return target;
|
|
15
|
+
}
|
|
16
|
+
for (const source of sources) {
|
|
17
|
+
if (!target.types) {
|
|
18
|
+
target.types = source.types;
|
|
19
|
+
} else if (source.types) {
|
|
20
|
+
mergeTypes(target.types, source.types);
|
|
21
|
+
}
|
|
22
|
+
if (!target.directives) {
|
|
23
|
+
target.directives = source.directives;
|
|
24
|
+
} else if ((_a = source.directives) == null ? void 0 : _a.length) {
|
|
25
|
+
mergeDirectives(target.directives, source.directives);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function mergeDirectives(target, source) {
|
|
30
|
+
for (const sourceDirective of source) {
|
|
31
|
+
const targetDirective = target.find(
|
|
32
|
+
(directive) => directive[DirectiveKeys.name] === sourceDirective[DirectiveKeys.name]
|
|
33
|
+
);
|
|
34
|
+
if (!targetDirective) {
|
|
35
|
+
target.push(sourceDirective);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (!sourceDirective[DirectiveKeys.arguments]) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (!targetDirective[DirectiveKeys.arguments]) {
|
|
42
|
+
targetDirective[DirectiveKeys.arguments] = sourceDirective[DirectiveKeys.arguments];
|
|
43
|
+
}
|
|
44
|
+
mergeInputValues(
|
|
45
|
+
targetDirective[DirectiveKeys.arguments],
|
|
46
|
+
sourceDirective[DirectiveKeys.arguments]
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function mergeTypes(target, source) {
|
|
51
|
+
for (const [typeName, sourceDef] of Object.entries(source)) {
|
|
52
|
+
const targetDef = target[typeName];
|
|
53
|
+
if (!targetDef) {
|
|
54
|
+
target[typeName] = sourceDef;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (targetDef[0] === TypeKind.OBJECT && sourceDef[0] === TypeKind.OBJECT) {
|
|
58
|
+
mergeFields(targetDef[ObjectKeys.fields], sourceDef[ObjectKeys.fields]);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (targetDef[0] === TypeKind.INTERFACE && sourceDef[0] === TypeKind.INTERFACE) {
|
|
62
|
+
mergeFields(
|
|
63
|
+
targetDef[InterfaceKeys.fields],
|
|
64
|
+
sourceDef[InterfaceKeys.fields]
|
|
65
|
+
);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (targetDef[0] === TypeKind.INPUT && sourceDef[0] === TypeKind.INPUT) {
|
|
69
|
+
mergeInputValues(
|
|
70
|
+
targetDef[InputObjectKeys.fields],
|
|
71
|
+
sourceDef[InputObjectKeys.fields]
|
|
72
|
+
);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (targetDef[0] !== sourceDef[0]) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Type ${typeName} is represented differently in different schema fragments:
|
|
78
|
+
` + inspect(targetDef) + `
|
|
79
|
+
` + inspect(sourceDef)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function mergeFields(target, source) {
|
|
85
|
+
for (const [fieldName, sourceDef] of Object.entries(source)) {
|
|
86
|
+
const targetDef = target[fieldName];
|
|
87
|
+
if (!target[fieldName] || !Array.isArray(targetDef)) {
|
|
88
|
+
target[fieldName] = sourceDef;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (Array.isArray(sourceDef) && sourceDef[FieldKeys.arguments]) {
|
|
92
|
+
if (!targetDef[FieldKeys.arguments]) {
|
|
93
|
+
targetDef[FieldKeys.arguments] = {};
|
|
94
|
+
}
|
|
95
|
+
mergeInputValues(
|
|
96
|
+
targetDef[FieldKeys.arguments],
|
|
97
|
+
sourceDef[FieldKeys.arguments]
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function mergeInputValues(target, source) {
|
|
103
|
+
for (const [fieldName, sourceDef] of Object.entries(source)) {
|
|
104
|
+
const targetDef = target[fieldName];
|
|
105
|
+
if (!target[fieldName] || !Array.isArray(targetDef)) {
|
|
106
|
+
target[fieldName] = sourceDef;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
mergeDirectives,
|
|
112
|
+
mergeSchemaDefinitions,
|
|
113
|
+
mergeTypes
|
|
114
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utilities/mergeDefinitions.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n DirectiveDefinitionTuple,\n DirectiveKeys,\n FieldDefinitionRecord,\n FieldKeys,\n InputObjectKeys,\n InputValueDefinitionRecord,\n InterfaceKeys,\n ObjectKeys,\n SchemaFragmentDefinitions,\n TypeDefinitionsRecord,\n TypeKind,\n} from \"../schema/definition\";\nimport { inspect } from \"../jsutils/inspect\";\n\nexport function mergeSchemaDefinitions(\n target: SchemaFragmentDefinitions,\n sources: SchemaFragmentDefinitions[],\n) {\n if (!sources.length) {\n return target;\n }\n for (const source of sources) {\n if (!target.types) {\n target.types = source.types;\n } else if (source.types) {\n mergeTypes(target.types, source.types);\n }\n if (!target.directives) {\n target.directives = source.directives;\n } else if (source.directives?.length) {\n mergeDirectives(target.directives, source.directives);\n }\n }\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 directive[DirectiveKeys.name] === sourceDirective[DirectiveKeys.name],\n );\n if (!targetDirective) {\n target.push(sourceDirective);\n continue;\n }\n if (!sourceDirective[DirectiveKeys.arguments]) {\n continue;\n }\n if (!targetDirective[DirectiveKeys.arguments]) {\n targetDirective[DirectiveKeys.arguments] =\n sourceDirective[DirectiveKeys.arguments];\n }\n mergeInputValues(\n targetDirective[DirectiveKeys.arguments],\n sourceDirective[DirectiveKeys.arguments],\n );\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 (targetDef[0] === TypeKind.OBJECT && sourceDef[0] === TypeKind.OBJECT) {\n mergeFields(targetDef[ObjectKeys.fields], sourceDef[ObjectKeys.fields]);\n // Note: not merging implemented interfaces - assuming they are fully defined by the first occurrence\n continue;\n }\n if (\n targetDef[0] === TypeKind.INTERFACE &&\n sourceDef[0] === TypeKind.INTERFACE\n ) {\n mergeFields(\n targetDef[InterfaceKeys.fields],\n sourceDef[InterfaceKeys.fields],\n );\n // Note: not merging implemented interfaces - assuming they are fully defined by the first occurrence\n continue;\n }\n if (targetDef[0] === TypeKind.INPUT && sourceDef[0] === TypeKind.INPUT) {\n mergeInputValues(\n targetDef[InputObjectKeys.fields],\n sourceDef[InputObjectKeys.fields],\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 if (Array.isArray(sourceDef) && sourceDef[FieldKeys.arguments]) {\n if (!targetDef[FieldKeys.arguments]) {\n targetDef[FieldKeys.arguments] = {};\n }\n mergeInputValues(\n targetDef[FieldKeys.arguments],\n sourceDef[FieldKeys.arguments],\n );\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": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { UserResolvers, Resolvers } from "../types";
|
|
2
|
-
export declare function mergeResolvers(resolvers: UserResolvers<
|
|
2
|
+
export declare function mergeResolvers<TSource, TContext>(resolvers: UserResolvers<TSource, TContext>, extractedResolvers: Resolvers<TSource, TContext>): Resolvers<TSource, TContext>;
|
|
3
3
|
//# sourceMappingURL=mergeResolvers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeResolvers.d.ts","sourceRoot":"","sources":["../../src/utilities/mergeResolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAY,MAAM,UAAU,CAAC;AAG9D,wBAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"mergeResolvers.d.ts","sourceRoot":"","sources":["../../src/utilities/mergeResolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAY,MAAM,UAAU,CAAC;AAG9D,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,EAC9C,SAAS,EAAE,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC3C,kBAAkB,EAAE,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,GAC/C,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAoB9B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utilities/mergeResolvers.ts"],
|
|
4
|
-
"sourcesContent": ["import { UserResolvers, Resolvers, Resolver } from \"../types\";\nimport { isObjectLike } from \"../jsutils/isObjectLike\";\n\nexport function mergeResolvers(\n resolvers: UserResolvers<
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAA6B;AAEtB,SAAS,eACd,WACA,
|
|
4
|
+
"sourcesContent": ["import { UserResolvers, Resolvers, Resolver } from \"../types\";\nimport { isObjectLike } from \"../jsutils/isObjectLike\";\n\nexport function mergeResolvers<TSource, TContext>(\n resolvers: UserResolvers<TSource, TContext>,\n extractedResolvers: Resolvers<TSource, TContext>,\n): Resolvers<TSource, TContext> {\n const fullResolvers = {\n ...extractedResolvers,\n } as Resolvers<TSource, TContext>;\n\n Object.keys(resolvers).forEach((resolverKey: string) => {\n if (isObjectLike(fullResolvers[resolverKey])) {\n fullResolvers[resolverKey] = {\n ...fullResolvers[resolverKey],\n ...resolvers[resolverKey],\n } as Resolver<unknown, unknown>;\n } else {\n fullResolvers[resolverKey] = resolvers[resolverKey] as Resolver<\n TSource,\n TContext\n >;\n }\n });\n\n return fullResolvers;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAA6B;AAEtB,SAAS,eACd,WACA,oBAC8B;AAC9B,QAAM,gBAAgB,mBACjB;AAGL,SAAO,KAAK,SAAS,EAAE,QAAQ,CAAC,gBAAwB;AACtD,YAAI,kCAAa,cAAc,WAAW,CAAC,GAAG;AAC5C,oBAAc,WAAW,IAAI,kCACxB,cAAc,WAAW,IACzB,UAAU,WAAW;AAAA,IAE5B,OAAO;AACL,oBAAc,WAAW,IAAI,UAAU,WAAW;AAAA,IAIpD;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utilities/mergeResolvers.ts"],
|
|
4
|
-
"sourcesContent": ["import { UserResolvers, Resolvers, Resolver } from \"../types\";\nimport { isObjectLike } from \"../jsutils/isObjectLike\";\n\nexport function mergeResolvers(\n resolvers: UserResolvers<
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AACA,SAAS,oBAAoB;AAEtB,SAAS,eACd,WACA,
|
|
4
|
+
"sourcesContent": ["import { UserResolvers, Resolvers, Resolver } from \"../types\";\nimport { isObjectLike } from \"../jsutils/isObjectLike\";\n\nexport function mergeResolvers<TSource, TContext>(\n resolvers: UserResolvers<TSource, TContext>,\n extractedResolvers: Resolvers<TSource, TContext>,\n): Resolvers<TSource, TContext> {\n const fullResolvers = {\n ...extractedResolvers,\n } as Resolvers<TSource, TContext>;\n\n Object.keys(resolvers).forEach((resolverKey: string) => {\n if (isObjectLike(fullResolvers[resolverKey])) {\n fullResolvers[resolverKey] = {\n ...fullResolvers[resolverKey],\n ...resolvers[resolverKey],\n } as Resolver<unknown, unknown>;\n } else {\n fullResolvers[resolverKey] = resolvers[resolverKey] as Resolver<\n TSource,\n TContext\n >;\n }\n });\n\n return fullResolvers;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AACA,SAAS,oBAAoB;AAEtB,SAAS,eACd,WACA,oBAC8B;AAC9B,QAAM,gBAAgB,mBACjB;AAGL,SAAO,KAAK,SAAS,EAAE,QAAQ,CAAC,gBAAwB;AACtD,QAAI,aAAa,cAAc,WAAW,CAAC,GAAG;AAC5C,oBAAc,WAAW,IAAI,kCACxB,cAAc,WAAW,IACzB,UAAU,WAAW;AAAA,IAE5B,OAAO;AACL,oBAAc,WAAW,IAAI,UAAU,WAAW;AAAA,IAIpD;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeNameFromAST.d.ts","sourceRoot":"","sources":["../../src/utilities/typeNameFromAST.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typeNameFromAST.d.ts","sourceRoot":"","sources":["../../src/utilities/typeNameFromAST.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAgB,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,MAAM,CAMzD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utilities/typeNameFromAST.ts"],
|
|
4
|
-
"sourcesContent": ["import { Kind
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { Kind, TypeNode } from \"graphql\";\n\nexport function typeNameFromAST(typeAst: TypeNode): string {\n if (typeAst.kind === Kind.LIST_TYPE || typeAst.kind === Kind.NON_NULL_TYPE) {\n return typeNameFromAST(typeAst.type);\n } else {\n return typeAst.name.value;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+B;AAExB,SAAS,gBAAgB,SAA2B;AACzD,MAAI,QAAQ,SAAS,oBAAK,aAAa,QAAQ,SAAS,oBAAK,eAAe;AAC1E,WAAO,gBAAgB,QAAQ,IAAI;AAAA,EACrC,OAAO;AACL,WAAO,QAAQ,KAAK;AAAA,EACtB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utilities/typeNameFromAST.ts"],
|
|
4
|
-
"sourcesContent": ["import { Kind
|
|
5
|
-
"mappings": ";AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { Kind, TypeNode } from \"graphql\";\n\nexport function typeNameFromAST(typeAst: TypeNode): string {\n if (typeAst.kind === Kind.LIST_TYPE || typeAst.kind === Kind.NON_NULL_TYPE) {\n return typeNameFromAST(typeAst.type);\n } else {\n return typeAst.name.value;\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,YAAsB;AAExB,SAAS,gBAAgB,SAA2B;AACzD,MAAI,QAAQ,SAAS,KAAK,aAAa,QAAQ,SAAS,KAAK,eAAe;AAC1E,WAAO,gBAAgB,QAAQ,IAAI;AAAA,EACrC,OAAO;AACL,WAAO,QAAQ,KAAK;AAAA,EACtB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Maybe } from "../jsutils/Maybe";
|
|
2
|
+
import type { ObjMap } from "../jsutils/ObjMap";
|
|
3
|
+
import { TypeReference } from "../schema/definition";
|
|
4
|
+
import { SchemaFragment } from "../schema/fragment";
|
|
5
|
+
import { ValueNode } from "graphql";
|
|
6
|
+
/**
|
|
7
|
+
* Produces a JavaScript value given a GraphQL Value AST.
|
|
8
|
+
*
|
|
9
|
+
* A GraphQL type must be provided, which will be used to interpret different
|
|
10
|
+
* GraphQL Value literals.
|
|
11
|
+
*
|
|
12
|
+
* Returns `undefined` when the value could not be validly coerced according to
|
|
13
|
+
* the provided type.
|
|
14
|
+
*
|
|
15
|
+
* | GraphQL Value | JSON Value |
|
|
16
|
+
* | -------------------- | ------------- |
|
|
17
|
+
* | Input Object | Object |
|
|
18
|
+
* | List | Array |
|
|
19
|
+
* | Boolean | Boolean |
|
|
20
|
+
* | String | String |
|
|
21
|
+
* | Int / Float | Number |
|
|
22
|
+
* | Enum Value | Unknown |
|
|
23
|
+
* | NullValue | null |
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export declare function valueFromAST(valueNode: Maybe<ValueNode>, typeRef: TypeReference, schemaTypes: SchemaFragment, variables?: Maybe<ObjMap<unknown>>): unknown;
|
|
27
|
+
//# sourceMappingURL=valueFromAST.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valueFromAST.d.ts","sourceRoot":"","sources":["../../src/utilities/valueFromAST.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAQ,MAAM,SAAS,CAAC;AAQ1C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,EAC3B,OAAO,EAAE,aAAa,EACtB,WAAW,EAAE,cAAc,EAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GACjC,OAAO,CAmIT"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var valueFromAST_exports = {};
|
|
20
|
+
__export(valueFromAST_exports, {
|
|
21
|
+
valueFromAST: () => valueFromAST
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(valueFromAST_exports);
|
|
24
|
+
var import_invariant = require("../jsutils/invariant");
|
|
25
|
+
var import_graphql = require("graphql");
|
|
26
|
+
var import_reference = require("../schema/reference");
|
|
27
|
+
function valueFromAST(valueNode, typeRef, schemaTypes, variables) {
|
|
28
|
+
if (!valueNode) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (valueNode.kind === import_graphql.Kind.VARIABLE) {
|
|
32
|
+
const variableName = valueNode.name.value;
|
|
33
|
+
if (variables == null || variables[variableName] === void 0) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const variableValue = variables[variableName];
|
|
37
|
+
if (variableValue === null && (0, import_reference.isNonNullType)(typeRef)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
return variableValue;
|
|
41
|
+
}
|
|
42
|
+
if ((0, import_reference.isNonNullType)(typeRef)) {
|
|
43
|
+
if (valueNode.kind === import_graphql.Kind.NULL) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
return valueFromAST(valueNode, (0, import_reference.unwrap)(typeRef), schemaTypes, variables);
|
|
47
|
+
}
|
|
48
|
+
if (valueNode.kind === import_graphql.Kind.NULL) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if ((0, import_reference.isListType)(typeRef)) {
|
|
52
|
+
const itemTypeRef = (0, import_reference.unwrap)(typeRef);
|
|
53
|
+
if (valueNode.kind === import_graphql.Kind.LIST) {
|
|
54
|
+
const coercedValues = [];
|
|
55
|
+
for (const itemNode of valueNode.values) {
|
|
56
|
+
if (isMissingVariable(itemNode, variables)) {
|
|
57
|
+
if ((0, import_reference.isNonNullType)(itemTypeRef)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
coercedValues.push(null);
|
|
61
|
+
} else {
|
|
62
|
+
const itemValue = valueFromAST(
|
|
63
|
+
itemNode,
|
|
64
|
+
itemTypeRef,
|
|
65
|
+
schemaTypes,
|
|
66
|
+
variables
|
|
67
|
+
);
|
|
68
|
+
if (itemValue === void 0) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
coercedValues.push(itemValue);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return coercedValues;
|
|
75
|
+
}
|
|
76
|
+
const coercedValue = valueFromAST(
|
|
77
|
+
valueNode,
|
|
78
|
+
itemTypeRef,
|
|
79
|
+
schemaTypes,
|
|
80
|
+
variables
|
|
81
|
+
);
|
|
82
|
+
if (coercedValue === void 0) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
return [coercedValue];
|
|
86
|
+
}
|
|
87
|
+
const inputObjectType = schemaTypes.getInputObjectType(typeRef);
|
|
88
|
+
if (inputObjectType) {
|
|
89
|
+
if (valueNode.kind !== import_graphql.Kind.OBJECT) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const coercedObj = /* @__PURE__ */ Object.create(null);
|
|
93
|
+
const fieldNodes = new Map(
|
|
94
|
+
valueNode.fields.map((field) => [field.name.value, field])
|
|
95
|
+
);
|
|
96
|
+
const fieldDefs = schemaTypes.getInputObjectFields(inputObjectType);
|
|
97
|
+
for (const [name, field] of Object.entries(fieldDefs)) {
|
|
98
|
+
const fieldNode = fieldNodes.get(name);
|
|
99
|
+
const fieldTypeRef = schemaTypes.getTypeReference(field);
|
|
100
|
+
if (fieldNode == null || isMissingVariable(fieldNode.value, variables)) {
|
|
101
|
+
const defaultValue = schemaTypes.getInputDefaultValue(field);
|
|
102
|
+
if (defaultValue !== void 0) {
|
|
103
|
+
coercedObj[name] = defaultValue;
|
|
104
|
+
} else if ((0, import_reference.isNonNullType)(fieldTypeRef)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const fieldValue = valueFromAST(
|
|
110
|
+
fieldNode.value,
|
|
111
|
+
fieldTypeRef,
|
|
112
|
+
schemaTypes,
|
|
113
|
+
variables
|
|
114
|
+
);
|
|
115
|
+
if (fieldValue === void 0) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
coercedObj[name] = fieldValue;
|
|
119
|
+
}
|
|
120
|
+
return coercedObj;
|
|
121
|
+
}
|
|
122
|
+
const leafType = schemaTypes.getLeafTypeResolver(typeRef);
|
|
123
|
+
if (leafType) {
|
|
124
|
+
let result;
|
|
125
|
+
try {
|
|
126
|
+
result = leafType.parseLiteral(valueNode, variables);
|
|
127
|
+
} catch (_error) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (result === void 0) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
(0, import_invariant.invariant)(false, "Unexpected input type: " + (0, import_reference.inspectTypeReference)(typeRef));
|
|
136
|
+
}
|
|
137
|
+
function isMissingVariable(valueNode, variables) {
|
|
138
|
+
return valueNode.kind === import_graphql.Kind.VARIABLE && (variables == null || variables[valueNode.name.value] === void 0);
|
|
139
|
+
}
|