@graphitation/supermassive 0.1.3 → 0.4.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/CHANGELOG.md +34 -2
- package/NOTICE +27 -0
- package/README.md +264 -2
- package/bin/supermassive.js +7 -0
- package/lib/{src/ast → ast}/TypedAST.d.ts +2 -0
- package/lib/ast/TypedAST.d.ts.map +1 -0
- package/lib/{src/ast → ast}/addTypesToRequestDocument.d.ts +0 -0
- package/lib/ast/addTypesToRequestDocument.d.ts.map +1 -0
- package/lib/ast/addTypesToRequestDocument.js +8 -5
- package/lib/ast/addTypesToRequestDocument.mjs +12 -6
- package/lib/benchmarks/index.d.ts.map +1 -1
- package/lib/benchmarks/index.js +127 -0
- package/lib/benchmarks/index.mjs +111 -0
- package/lib/benchmarks/nice-benchmark.d.ts +1 -1
- package/lib/benchmarks/nice-benchmark.d.ts.map +1 -1
- package/lib/benchmarks/nice-benchmark.js +72 -0
- package/lib/benchmarks/nice-benchmark.mjs +52 -0
- package/lib/benchmarks/swapi-schema/index.d.ts +1 -0
- package/lib/benchmarks/swapi-schema/index.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/index.js +39 -0
- package/lib/benchmarks/swapi-schema/index.mjs +17 -0
- package/lib/benchmarks/swapi-schema/models.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/models.js +29 -0
- package/lib/benchmarks/swapi-schema/models.mjs +7 -0
- package/lib/benchmarks/swapi-schema/resolvers.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/resolvers.js +237 -0
- package/lib/benchmarks/swapi-schema/resolvers.mjs +230 -0
- package/lib/bin/supermassive.d.ts +3 -0
- package/lib/bin/supermassive.d.ts.map +1 -0
- package/lib/bin/supermassive.js +83 -0
- package/lib/bin/supermassive.mjs +62 -0
- package/lib/collectFields.d.ts +17 -0
- package/lib/collectFields.d.ts.map +1 -0
- package/lib/collectFields.js +83 -0
- package/lib/collectFields.mjs +61 -0
- package/lib/compiledQuery.d.ts +1 -0
- package/lib/compiledQuery.d.ts.map +1 -0
- package/lib/compiledQuery.js +0 -0
- package/lib/compiledQuery.mjs +0 -0
- package/lib/executeWithSchema.d.ts +4 -0
- package/lib/executeWithSchema.d.ts.map +1 -0
- package/lib/{index.test.js → executeWithSchema.js} +45 -46
- package/lib/executeWithSchema.mjs +64 -0
- package/lib/executeWithoutSchema.d.ts +99 -0
- package/lib/executeWithoutSchema.d.ts.map +1 -0
- package/lib/executeWithoutSchema.js +376 -0
- package/lib/executeWithoutSchema.mjs +363 -0
- package/lib/extractImplicitTypesRuntime.d.ts +4 -0
- package/lib/extractImplicitTypesRuntime.d.ts.map +1 -0
- package/lib/extractImplicitTypesRuntime.js +103 -0
- package/lib/extractImplicitTypesRuntime.mjs +91 -0
- package/lib/extractImplicitTypesToTypescript.d.ts +4 -0
- package/lib/extractImplicitTypesToTypescript.d.ts.map +1 -0
- package/lib/extractImplicitTypesToTypescript.js +169 -0
- package/lib/extractImplicitTypesToTypescript.mjs +149 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -29
- package/lib/index.mjs +13 -29
- package/lib/jsutils/Maybe.d.ts +3 -0
- package/lib/jsutils/Maybe.d.ts.map +1 -0
- package/lib/jsutils/Maybe.js +3 -0
- package/lib/jsutils/Maybe.mjs +0 -0
- package/lib/jsutils/ObjMap.d.ts +13 -0
- package/lib/jsutils/ObjMap.d.ts.map +1 -0
- package/lib/jsutils/ObjMap.js +3 -0
- package/lib/jsutils/ObjMap.mjs +0 -0
- package/lib/jsutils/Path.d.ts +15 -0
- package/lib/jsutils/Path.d.ts.map +1 -0
- package/lib/jsutils/Path.js +23 -0
- package/lib/jsutils/Path.mjs +17 -0
- package/lib/jsutils/PromiseOrValue.d.ts +2 -0
- package/lib/jsutils/PromiseOrValue.d.ts.map +1 -0
- package/lib/jsutils/PromiseOrValue.js +3 -0
- package/lib/jsutils/PromiseOrValue.mjs +0 -0
- package/lib/jsutils/devAssert.d.ts +2 -0
- package/lib/jsutils/devAssert.d.ts.map +1 -0
- package/lib/jsutils/devAssert.js +16 -0
- package/lib/jsutils/devAssert.mjs +10 -0
- package/lib/jsutils/didYouMean.d.ts +6 -0
- package/lib/jsutils/didYouMean.d.ts.map +1 -0
- package/lib/jsutils/didYouMean.js +30 -0
- package/lib/jsutils/didYouMean.mjs +24 -0
- package/lib/jsutils/identityFunc.d.ts +5 -0
- package/lib/jsutils/identityFunc.d.ts.map +1 -0
- package/lib/jsutils/identityFunc.js +13 -0
- package/lib/jsutils/identityFunc.mjs +7 -0
- package/lib/jsutils/inspect.d.ts +5 -0
- package/lib/jsutils/inspect.d.ts.map +1 -0
- package/lib/jsutils/inspect.js +89 -0
- package/lib/jsutils/inspect.mjs +83 -0
- package/lib/jsutils/instanceOf.d.ts +14 -0
- package/lib/jsutils/instanceOf.d.ts.map +1 -0
- package/lib/jsutils/instanceOf.js +55 -0
- package/lib/jsutils/instanceOf.mjs +33 -0
- package/lib/jsutils/invariant.d.ts +2 -0
- package/lib/jsutils/invariant.d.ts.map +1 -0
- package/lib/jsutils/invariant.js +16 -0
- package/lib/jsutils/invariant.mjs +10 -0
- package/lib/jsutils/isAsyncIterable.d.ts +6 -0
- package/lib/jsutils/isAsyncIterable.d.ts.map +1 -0
- package/lib/jsutils/isAsyncIterable.js +13 -0
- package/lib/jsutils/isAsyncIterable.mjs +7 -0
- package/lib/jsutils/isIterableObject.d.ts +18 -0
- package/lib/jsutils/isIterableObject.d.ts.map +1 -0
- package/lib/jsutils/isIterableObject.js +13 -0
- package/lib/jsutils/isIterableObject.mjs +7 -0
- package/lib/jsutils/isObjectLike.d.ts +8 -0
- package/lib/jsutils/isObjectLike.d.ts.map +1 -0
- package/lib/jsutils/isObjectLike.js +13 -0
- package/lib/jsutils/isObjectLike.mjs +7 -0
- package/lib/jsutils/isPromise.d.ts +6 -0
- package/lib/jsutils/isPromise.d.ts.map +1 -0
- package/lib/jsutils/isPromise.js +13 -0
- package/lib/jsutils/isPromise.mjs +7 -0
- package/lib/jsutils/keyMap.d.ts +26 -0
- package/lib/jsutils/keyMap.d.ts.map +1 -0
- package/lib/jsutils/keyMap.js +17 -0
- package/lib/jsutils/keyMap.mjs +11 -0
- package/lib/jsutils/keyValMap.d.ts +20 -0
- package/lib/jsutils/keyValMap.d.ts.map +1 -0
- package/lib/jsutils/keyValMap.js +17 -0
- package/lib/jsutils/keyValMap.mjs +11 -0
- package/lib/jsutils/mapValue.d.ts +7 -0
- package/lib/jsutils/mapValue.d.ts.map +1 -0
- package/lib/jsutils/mapValue.js +17 -0
- package/lib/jsutils/mapValue.mjs +11 -0
- package/lib/jsutils/memoize3.d.ts +5 -0
- package/lib/jsutils/memoize3.d.ts.map +1 -0
- package/lib/jsutils/memoize3.js +34 -0
- package/lib/jsutils/memoize3.mjs +28 -0
- package/lib/jsutils/naturalCompare.d.ts +9 -0
- package/lib/jsutils/naturalCompare.d.ts.map +1 -0
- package/lib/jsutils/naturalCompare.js +53 -0
- package/lib/jsutils/naturalCompare.mjs +47 -0
- package/lib/jsutils/printPathArray.d.ts +5 -0
- package/lib/jsutils/printPathArray.d.ts.map +1 -0
- package/lib/jsutils/printPathArray.js +13 -0
- package/lib/jsutils/printPathArray.mjs +7 -0
- package/lib/jsutils/promiseForObject.d.ts +10 -0
- package/lib/jsutils/promiseForObject.d.ts.map +1 -0
- package/lib/jsutils/promiseForObject.js +19 -0
- package/lib/jsutils/promiseForObject.mjs +13 -0
- package/lib/jsutils/promiseReduce.d.ts +10 -0
- package/lib/jsutils/promiseReduce.d.ts.map +1 -0
- package/lib/jsutils/promiseReduce.js +34 -0
- package/lib/jsutils/promiseReduce.mjs +12 -0
- package/lib/jsutils/suggestionList.d.ts +6 -0
- package/lib/jsutils/suggestionList.d.ts.map +1 -0
- package/lib/jsutils/suggestionList.js +109 -0
- package/lib/jsutils/suggestionList.mjs +87 -0
- package/lib/jsutils/toObjMap.d.ts +4 -0
- package/lib/jsutils/toObjMap.d.ts.map +1 -0
- package/lib/jsutils/toObjMap.js +20 -0
- package/lib/jsutils/toObjMap.mjs +14 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.d.ts +3 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.d.ts.map +1 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.js +37 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.mjs +17 -0
- package/lib/transforms/transformerTestUtils.d.ts +79 -0
- package/lib/transforms/transformerTestUtils.d.ts.map +1 -0
- package/lib/transforms/transformerTestUtils.js +175 -0
- package/lib/transforms/transformerTestUtils.mjs +160 -0
- package/lib/types.d.ts +74 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.mjs +0 -0
- package/lib/utilities/typeNameFromAST.d.ts +3 -0
- package/lib/utilities/typeNameFromAST.d.ts.map +1 -0
- package/lib/utilities/typeNameFromAST.js +34 -0
- package/lib/utilities/typeNameFromAST.mjs +12 -0
- package/lib/values.d.ts +64 -0
- package/lib/values.d.ts.map +1 -0
- package/lib/values.js +145 -0
- package/lib/values.mjs +138 -0
- package/package.json +21 -6
- package/.eslintcache +0 -1
- package/CHANGELOG.json +0 -65
- package/benchmarks/fixtures/query1.graphql +0 -20
- package/benchmarks/index.ts +0 -68
- package/benchmarks/nice-benchmark.ts +0 -32
- package/benchmarks/swapi-schema/index.ts +0 -13
- package/benchmarks/swapi-schema/models.ts +0 -4
- package/benchmarks/swapi-schema/resolvers.ts +0 -331
- package/benchmarks/swapi-schema/schema.graphql +0 -164
- package/benchmarks/swapi-schema/starwars.json +0 -5991
- package/lib/index.test.mjs +0 -63
- package/lib/src/ast/TypedAST.d.ts.map +0 -1
- package/lib/src/ast/addTypesToRequestDocument.d.ts.map +0 -1
- package/lib/src/index.d.ts +0 -16
- package/lib/src/index.d.ts.map +0 -1
- package/lib/src/index.test.d.ts +0 -2
- package/lib/src/index.test.d.ts.map +0 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
6
|
+
var __objSpread = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/executeWithSchema.ts
|
|
19
|
+
import {makeExecutableSchema} from "@graphql-tools/schema";
|
|
20
|
+
import {isInputType} from "graphql";
|
|
21
|
+
import {
|
|
22
|
+
addTypesToRequestDocument,
|
|
23
|
+
executeWithoutSchema,
|
|
24
|
+
extractImplicitTypes,
|
|
25
|
+
specifiedScalars
|
|
26
|
+
} from "./index.mjs";
|
|
27
|
+
function executeWithSchema({
|
|
28
|
+
typeDefs,
|
|
29
|
+
resolvers,
|
|
30
|
+
document: rawDocument,
|
|
31
|
+
rootValue,
|
|
32
|
+
contextValue,
|
|
33
|
+
variableValues,
|
|
34
|
+
operationName,
|
|
35
|
+
fieldResolver,
|
|
36
|
+
typeResolver
|
|
37
|
+
}) {
|
|
38
|
+
const schema = makeExecutableSchema({typeDefs, resolvers});
|
|
39
|
+
let extractedResolvers = {};
|
|
40
|
+
const getTypeByName = (name) => {
|
|
41
|
+
const type = specifiedScalars[name] || extractedResolvers[name];
|
|
42
|
+
if (isInputType(type)) {
|
|
43
|
+
return type;
|
|
44
|
+
} else {
|
|
45
|
+
throw new Error("Invalid type");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
extractedResolvers = extractImplicitTypes(typeDefs, getTypeByName);
|
|
49
|
+
const fullResolvers = __objSpread(__objSpread({}, extractedResolvers), resolvers);
|
|
50
|
+
const document = addTypesToRequestDocument(schema, rawDocument);
|
|
51
|
+
return executeWithoutSchema({
|
|
52
|
+
document,
|
|
53
|
+
resolvers: fullResolvers,
|
|
54
|
+
rootValue,
|
|
55
|
+
contextValue,
|
|
56
|
+
variableValues,
|
|
57
|
+
operationName,
|
|
58
|
+
fieldResolver,
|
|
59
|
+
typeResolver
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
executeWithSchema
|
|
64
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { GraphQLError } from "graphql";
|
|
2
|
+
import { DocumentNode, FieldNode, FragmentDefinitionNode, OperationDefinitionNode, TypeNode } from "./ast/TypedAST";
|
|
3
|
+
import type { Maybe } from "./jsutils/Maybe";
|
|
4
|
+
import type { ObjMap } from "./jsutils/ObjMap";
|
|
5
|
+
import type { Path } from "./jsutils/Path";
|
|
6
|
+
import type { PromiseOrValue } from "./jsutils/PromiseOrValue";
|
|
7
|
+
import { ExecutionWithoutSchemaArgs, FieldResolver, ResolveInfo, Resolvers, TypeResolver, ExecutionResult } from "./types";
|
|
8
|
+
/**
|
|
9
|
+
* Terminology
|
|
10
|
+
*
|
|
11
|
+
* "Definitions" are the generic name for top-level statements in the document.
|
|
12
|
+
* Examples of this include:
|
|
13
|
+
* 1) Operations (such as a query)
|
|
14
|
+
* 2) Fragments
|
|
15
|
+
*
|
|
16
|
+
* "Operations" are a generic name for requests in the document.
|
|
17
|
+
* Examples of this include:
|
|
18
|
+
* 1) query,
|
|
19
|
+
* 2) mutation
|
|
20
|
+
*
|
|
21
|
+
* "Selections" are the definitions that can appear legally and at
|
|
22
|
+
* single level of the query. These include:
|
|
23
|
+
* 1) field references e.g "a"
|
|
24
|
+
* 2) fragment "spreads" e.g. "...c"
|
|
25
|
+
* 3) inline fragment "spreads" e.g. "...on Type { a }"
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Data that must be available at all points during query execution.
|
|
29
|
+
*
|
|
30
|
+
* Namely, schema of the type system that is currently executing,
|
|
31
|
+
* and the fragments defined in the query document
|
|
32
|
+
*/
|
|
33
|
+
export interface ExecutionContext {
|
|
34
|
+
resolvers: Resolvers;
|
|
35
|
+
fragments: ObjMap<FragmentDefinitionNode>;
|
|
36
|
+
rootValue: unknown;
|
|
37
|
+
contextValue: unknown;
|
|
38
|
+
operation: OperationDefinitionNode;
|
|
39
|
+
variableValues: {
|
|
40
|
+
[variable: string]: unknown;
|
|
41
|
+
};
|
|
42
|
+
fieldResolver: FieldResolver<any, any>;
|
|
43
|
+
typeResolver: TypeResolver<any, any>;
|
|
44
|
+
errors: Array<GraphQLError>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Implements the "Executing requests" section of the GraphQL specification.
|
|
48
|
+
*
|
|
49
|
+
* Returns either a synchronous ExecutionResult (if all encountered resolvers
|
|
50
|
+
* are synchronous), or a Promise of an ExecutionResult that will eventually be
|
|
51
|
+
* resolved and never rejected.
|
|
52
|
+
*
|
|
53
|
+
* If the arguments to this function do not result in a legal execution context,
|
|
54
|
+
* a GraphQLError will be thrown immediately explaining the invalid input.
|
|
55
|
+
*/
|
|
56
|
+
export declare function executeWithoutSchema(args: ExecutionWithoutSchemaArgs): PromiseOrValue<ExecutionResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Essential assertions before executing to provide developer feedback for
|
|
59
|
+
* improper use of the GraphQL library.
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare function assertValidExecutionArguments(document: DocumentNode, rawVariableValues: Maybe<{
|
|
64
|
+
[variable: string]: unknown;
|
|
65
|
+
}>): void;
|
|
66
|
+
/**
|
|
67
|
+
* Constructs a ExecutionContext object from the arguments passed to
|
|
68
|
+
* execute, which we will pass throughout the other execution methods.
|
|
69
|
+
*
|
|
70
|
+
* Throws a GraphQLError if a valid execution context cannot be created.
|
|
71
|
+
*
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
export declare function buildExecutionContext(resolvers: Resolvers, document: DocumentNode, rootValue: unknown, contextValue: unknown, rawVariableValues: Maybe<{
|
|
75
|
+
[variable: string]: unknown;
|
|
76
|
+
}>, operationName: Maybe<string>, fieldResolver: Maybe<FieldResolver<unknown, unknown>>, typeResolver?: Maybe<TypeResolver<unknown, unknown>>): Array<GraphQLError> | ExecutionContext;
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
export declare function buildResolveInfo(exeContext: ExecutionContext, fieldName: string, fieldNodes: Array<FieldNode>, parentTypeName: string, returnTypeName: string, returnTypeNode: TypeNode, path: Path): ResolveInfo;
|
|
81
|
+
/**
|
|
82
|
+
* If a resolveType function is not given, then a default resolve behavior is
|
|
83
|
+
* used which attempts two strategies:
|
|
84
|
+
*
|
|
85
|
+
* First, See if the provided value has a `__typename` field defined, if so, use
|
|
86
|
+
* that value as name of the resolved type.
|
|
87
|
+
*
|
|
88
|
+
* Otherwise, test each possible type for the abstract type by calling
|
|
89
|
+
* isTypeOf for the object being coerced, returning the first type that matches.
|
|
90
|
+
*/
|
|
91
|
+
export declare const defaultTypeResolver: TypeResolver<unknown, unknown>;
|
|
92
|
+
/**
|
|
93
|
+
* If a resolve function is not given, then a default resolve behavior is used
|
|
94
|
+
* which takes the property of the source object of the same name as the field
|
|
95
|
+
* and returns it as the result, or if it's a function, returns the result
|
|
96
|
+
* of calling that function while passing along args and context value.
|
|
97
|
+
*/
|
|
98
|
+
export declare const defaultFieldResolver: FieldResolver<unknown, unknown>;
|
|
99
|
+
//# sourceMappingURL=executeWithoutSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeWithoutSchema.d.ts","sourceRoot":"","sources":["../src/executeWithoutSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EASb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,YAAY,EACZ,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EAEvB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAQxB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EACL,0BAA0B,EAC1B,aAAa,EAGb,WAAW,EAEX,SAAS,EACT,YAAY,EAEZ,eAAe,EAChB,MAAM,SAAS,CAAC;AAQjB;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC,sBAAsB,CAAC,CAAC;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,uBAAuB,CAAC;IACnC,cAAc,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAChD,aAAa,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACvC,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,0BAA0B,GAC/B,cAAc,CAAC,eAAe,CAAC,CA0CjC;AAoBD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,YAAY,EACtB,iBAAiB,EAAE,KAAK,CAAC;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,GACxD,IAAI,CAQN;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,OAAO,EAClB,YAAY,EAAE,OAAO,EACrB,iBAAiB,EAAE,KAAK,CAAC;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,EACzD,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,EAC5B,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,EACrD,YAAY,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,GACnD,KAAK,CAAC,YAAY,CAAC,GAAG,gBAAgB,CAyDxC;AAgPD;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,gBAAgB,EAC5B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,EAC5B,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,QAAQ,EACxB,IAAI,EAAE,IAAI,GACT,WAAW,CAeb;AAoWD;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAM9D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,CAchE,CAAC"}
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toModule = (module2) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
+
};
|
|
23
|
+
__markAsModule(exports);
|
|
24
|
+
__export(exports, {
|
|
25
|
+
assertValidExecutionArguments: () => assertValidExecutionArguments,
|
|
26
|
+
buildExecutionContext: () => buildExecutionContext,
|
|
27
|
+
buildResolveInfo: () => buildResolveInfo,
|
|
28
|
+
defaultFieldResolver: () => defaultFieldResolver,
|
|
29
|
+
defaultTypeResolver: () => defaultTypeResolver,
|
|
30
|
+
executeWithoutSchema: () => executeWithoutSchema
|
|
31
|
+
});
|
|
32
|
+
var import_graphql = __toModule(require("graphql"));
|
|
33
|
+
var import_collectFields = __toModule(require("./collectFields"));
|
|
34
|
+
var import_devAssert = __toModule(require("./jsutils/devAssert"));
|
|
35
|
+
var import_inspect = __toModule(require("./jsutils/inspect"));
|
|
36
|
+
var import_invariant = __toModule(require("./jsutils/invariant"));
|
|
37
|
+
var import_isIterableObject = __toModule(require("./jsutils/isIterableObject"));
|
|
38
|
+
var import_isObjectLike = __toModule(require("./jsutils/isObjectLike"));
|
|
39
|
+
var import_isPromise = __toModule(require("./jsutils/isPromise"));
|
|
40
|
+
var import_Path = __toModule(require("./jsutils/Path"));
|
|
41
|
+
var import_promiseForObject = __toModule(require("./jsutils/promiseForObject"));
|
|
42
|
+
var import_promiseReduce = __toModule(require("./jsutils/promiseReduce"));
|
|
43
|
+
var import_typeNameFromAST = __toModule(require("./utilities/typeNameFromAST"));
|
|
44
|
+
var import_values = __toModule(require("./values"));
|
|
45
|
+
function executeWithoutSchema(args) {
|
|
46
|
+
const {
|
|
47
|
+
resolvers,
|
|
48
|
+
document,
|
|
49
|
+
rootValue,
|
|
50
|
+
contextValue,
|
|
51
|
+
variableValues,
|
|
52
|
+
operationName,
|
|
53
|
+
fieldResolver,
|
|
54
|
+
typeResolver
|
|
55
|
+
} = args;
|
|
56
|
+
assertValidExecutionArguments(document, variableValues);
|
|
57
|
+
const exeContext = buildExecutionContext(resolvers, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver);
|
|
58
|
+
if (!("resolvers" in exeContext)) {
|
|
59
|
+
return {errors: exeContext};
|
|
60
|
+
} else {
|
|
61
|
+
const data = executeOperation(exeContext, exeContext.operation, rootValue);
|
|
62
|
+
return buildResponse(exeContext, data);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function buildResponse(exeContext, data) {
|
|
66
|
+
if ((0, import_isPromise.isPromise)(data)) {
|
|
67
|
+
return data.then((resolved) => buildResponse(exeContext, resolved));
|
|
68
|
+
}
|
|
69
|
+
return exeContext.errors.length === 0 ? {data} : {errors: exeContext.errors, data};
|
|
70
|
+
}
|
|
71
|
+
function assertValidExecutionArguments(document, rawVariableValues) {
|
|
72
|
+
(0, import_devAssert.devAssert)(document, "Must provide document.");
|
|
73
|
+
(0, import_devAssert.devAssert)(rawVariableValues == null || (0, import_isObjectLike.isObjectLike)(rawVariableValues), "Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.");
|
|
74
|
+
}
|
|
75
|
+
function buildExecutionContext(resolvers, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver) {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
let operation;
|
|
78
|
+
const fragments = Object.create(null);
|
|
79
|
+
for (const definition of document.definitions) {
|
|
80
|
+
switch (definition.kind) {
|
|
81
|
+
case import_graphql.Kind.OPERATION_DEFINITION:
|
|
82
|
+
if (operationName == null) {
|
|
83
|
+
if (operation !== void 0) {
|
|
84
|
+
return [
|
|
85
|
+
new import_graphql.GraphQLError("Must provide operation name if query contains multiple operations.")
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
operation = definition;
|
|
89
|
+
} else if (((_a = definition.name) == null ? void 0 : _a.value) === operationName) {
|
|
90
|
+
operation = definition;
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
case import_graphql.Kind.FRAGMENT_DEFINITION:
|
|
94
|
+
fragments[definition.name.value] = definition;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!operation) {
|
|
99
|
+
if (operationName != null) {
|
|
100
|
+
return [new import_graphql.GraphQLError(`Unknown operation named "${operationName}".`)];
|
|
101
|
+
}
|
|
102
|
+
return [new import_graphql.GraphQLError("Must provide an operation.")];
|
|
103
|
+
}
|
|
104
|
+
const variableDefinitions = (_b = operation.variableDefinitions) != null ? _b : [];
|
|
105
|
+
const coercedVariableValues = (0, import_values.getVariableValues)(resolvers, variableDefinitions, rawVariableValues != null ? rawVariableValues : {}, {maxErrors: 50});
|
|
106
|
+
if (coercedVariableValues.errors) {
|
|
107
|
+
return coercedVariableValues.errors;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
resolvers,
|
|
111
|
+
fragments,
|
|
112
|
+
rootValue,
|
|
113
|
+
contextValue,
|
|
114
|
+
operation,
|
|
115
|
+
variableValues: coercedVariableValues.coerced,
|
|
116
|
+
fieldResolver: fieldResolver != null ? fieldResolver : defaultFieldResolver,
|
|
117
|
+
typeResolver: typeResolver != null ? typeResolver : defaultTypeResolver,
|
|
118
|
+
errors: []
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function executeOperation(exeContext, operation, rootValue) {
|
|
122
|
+
const typeName = getOperationRootTypeName(operation);
|
|
123
|
+
const fields = (0, import_collectFields.collectFields)(exeContext.resolvers, exeContext.fragments, exeContext.variableValues, typeName, operation.selectionSet, new Map(), new Set());
|
|
124
|
+
const path = void 0;
|
|
125
|
+
try {
|
|
126
|
+
const result = operation.operation === "mutation" ? executeFieldsSerially(exeContext, typeName, rootValue, path, fields) : executeFields(exeContext, typeName, rootValue, path, fields);
|
|
127
|
+
if ((0, import_isPromise.isPromise)(result)) {
|
|
128
|
+
return result.then(void 0, (error) => {
|
|
129
|
+
exeContext.errors.push(error);
|
|
130
|
+
return Promise.resolve(null);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
exeContext.errors.push(error);
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, fields) {
|
|
140
|
+
return (0, import_promiseReduce.promiseReduce)(fields.entries(), (results, [responseName, fieldNodes]) => {
|
|
141
|
+
const fieldPath = (0, import_Path.addPath)(path, responseName, parentTypeName);
|
|
142
|
+
const result = executeField(exeContext, parentTypeName, sourceValue, fieldNodes, fieldPath);
|
|
143
|
+
if (result === void 0) {
|
|
144
|
+
return results;
|
|
145
|
+
}
|
|
146
|
+
if ((0, import_isPromise.isPromise)(result)) {
|
|
147
|
+
return result.then((resolvedResult) => {
|
|
148
|
+
results[responseName] = resolvedResult;
|
|
149
|
+
return results;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
results[responseName] = result;
|
|
153
|
+
return results;
|
|
154
|
+
}, Object.create(null));
|
|
155
|
+
}
|
|
156
|
+
function executeFields(exeContext, parentTypeName, sourceValue, path, fields) {
|
|
157
|
+
const results = Object.create(null);
|
|
158
|
+
let containsPromise = false;
|
|
159
|
+
for (const [responseName, fieldNodes] of fields.entries()) {
|
|
160
|
+
const fieldPath = (0, import_Path.addPath)(path, responseName, parentTypeName);
|
|
161
|
+
const result = executeField(exeContext, parentTypeName, sourceValue, fieldNodes, fieldPath);
|
|
162
|
+
if (result !== void 0) {
|
|
163
|
+
results[responseName] = result;
|
|
164
|
+
if ((0, import_isPromise.isPromise)(result)) {
|
|
165
|
+
containsPromise = true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (!containsPromise) {
|
|
170
|
+
return results;
|
|
171
|
+
}
|
|
172
|
+
return (0, import_promiseForObject.promiseForObject)(results);
|
|
173
|
+
}
|
|
174
|
+
function executeField(exeContext, parentTypeName, source, fieldNodes, path) {
|
|
175
|
+
const fieldName = fieldNodes[0].name.value;
|
|
176
|
+
let resolveFn;
|
|
177
|
+
let returnTypeName;
|
|
178
|
+
let returnTypeNode;
|
|
179
|
+
if (fieldName === "__typename" && !resolveFn) {
|
|
180
|
+
resolveFn = () => parentTypeName;
|
|
181
|
+
returnTypeName = "String";
|
|
182
|
+
returnTypeNode = {
|
|
183
|
+
kind: import_graphql.Kind.NAMED_TYPE,
|
|
184
|
+
name: {
|
|
185
|
+
kind: import_graphql.Kind.NAME,
|
|
186
|
+
value: "String"
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
} else {
|
|
190
|
+
returnTypeNode = fieldNodes[0].__type;
|
|
191
|
+
returnTypeName = (0, import_typeNameFromAST.typeNameFromAST)(returnTypeNode);
|
|
192
|
+
const typeResolvers = exeContext.resolvers[parentTypeName];
|
|
193
|
+
resolveFn = typeResolvers == null ? void 0 : typeResolvers[fieldName];
|
|
194
|
+
}
|
|
195
|
+
if (!resolveFn) {
|
|
196
|
+
resolveFn = exeContext.fieldResolver;
|
|
197
|
+
}
|
|
198
|
+
const info = buildResolveInfo(exeContext, fieldName, fieldNodes, parentTypeName, returnTypeName, returnTypeNode, path);
|
|
199
|
+
try {
|
|
200
|
+
const args = (0, import_values.getArgumentValues)(exeContext.resolvers, fieldNodes[0], exeContext.variableValues);
|
|
201
|
+
const contextValue = exeContext.contextValue;
|
|
202
|
+
const result = resolveFn(source, args, contextValue, info);
|
|
203
|
+
let completed;
|
|
204
|
+
if ((0, import_isPromise.isPromise)(result)) {
|
|
205
|
+
completed = result.then((resolved) => completeValue(exeContext, returnTypeNode, fieldNodes, info, path, resolved));
|
|
206
|
+
} else {
|
|
207
|
+
completed = completeValue(exeContext, returnTypeNode, fieldNodes, info, path, result);
|
|
208
|
+
}
|
|
209
|
+
if ((0, import_isPromise.isPromise)(completed)) {
|
|
210
|
+
return completed.then(void 0, (rawError) => {
|
|
211
|
+
const error = (0, import_graphql.locatedError)(rawError, fieldNodes, (0, import_Path.pathToArray)(path));
|
|
212
|
+
return handleFieldError(error, returnTypeNode, exeContext);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return completed;
|
|
216
|
+
} catch (rawError) {
|
|
217
|
+
const error = (0, import_graphql.locatedError)(rawError, fieldNodes, (0, import_Path.pathToArray)(path));
|
|
218
|
+
return handleFieldError(error, returnTypeNode, exeContext);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function buildResolveInfo(exeContext, fieldName, fieldNodes, parentTypeName, returnTypeName, returnTypeNode, path) {
|
|
222
|
+
return {
|
|
223
|
+
fieldName,
|
|
224
|
+
fieldNodes,
|
|
225
|
+
returnTypeName,
|
|
226
|
+
parentTypeName,
|
|
227
|
+
returnTypeNode,
|
|
228
|
+
path,
|
|
229
|
+
fragments: exeContext.fragments,
|
|
230
|
+
rootValue: exeContext.rootValue,
|
|
231
|
+
operation: exeContext.operation,
|
|
232
|
+
variableValues: exeContext.variableValues
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function handleFieldError(error, returnTypeNode, exeContext) {
|
|
236
|
+
if (returnTypeNode.kind === import_graphql.Kind.NON_NULL_TYPE) {
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
exeContext.errors.push(error);
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
function completeValue(exeContext, returnTypeNode, fieldNodes, info, path, result) {
|
|
243
|
+
if (result instanceof Error) {
|
|
244
|
+
throw result;
|
|
245
|
+
}
|
|
246
|
+
if (returnTypeNode.kind === import_graphql.Kind.NON_NULL_TYPE) {
|
|
247
|
+
const completed = completeValue(exeContext, returnTypeNode.type, fieldNodes, info, path, result);
|
|
248
|
+
if (completed === null) {
|
|
249
|
+
throw new Error(`Cannot return null for non-nullable field ${info.parentTypeName}.${info.fieldName}.`);
|
|
250
|
+
}
|
|
251
|
+
return completed;
|
|
252
|
+
}
|
|
253
|
+
if (result == null) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
if (returnTypeNode.kind === import_graphql.Kind.LIST_TYPE) {
|
|
257
|
+
return completeListValue(exeContext, returnTypeNode.type, fieldNodes, info, path, result);
|
|
258
|
+
}
|
|
259
|
+
const returnTypeName = returnTypeNode.name.value;
|
|
260
|
+
let returnType = exeContext.resolvers[returnTypeName];
|
|
261
|
+
if (!returnType) {
|
|
262
|
+
returnType = import_values.specifiedScalars[returnTypeName];
|
|
263
|
+
}
|
|
264
|
+
if ((0, import_graphql.isLeafType)(returnType)) {
|
|
265
|
+
return completeLeafValue(returnType, result);
|
|
266
|
+
}
|
|
267
|
+
if (returnType instanceof import_graphql.GraphQLInputObjectType) {
|
|
268
|
+
}
|
|
269
|
+
if ("__resolveType" in returnType) {
|
|
270
|
+
return completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result);
|
|
271
|
+
}
|
|
272
|
+
if (typeof returnType === "object") {
|
|
273
|
+
return completeObjectValue(exeContext, returnTypeName, fieldNodes, info, path, result);
|
|
274
|
+
}
|
|
275
|
+
(0, import_invariant.invariant)(false, "Cannot complete value of unexpected output type: " + (0, import_inspect.inspect)(returnType));
|
|
276
|
+
}
|
|
277
|
+
function completeListValue(exeContext, returnTypeNode, fieldNodes, info, path, result) {
|
|
278
|
+
if (!(0, import_isIterableObject.isIterableObject)(result)) {
|
|
279
|
+
throw new import_graphql.GraphQLError(`Expected Iterable, but did not find one for field "${info.parentTypeName}.${info.fieldName}".`);
|
|
280
|
+
}
|
|
281
|
+
let containsPromise = false;
|
|
282
|
+
const completedResults = Array.from(result, (item, index) => {
|
|
283
|
+
const itemPath = (0, import_Path.addPath)(path, index, void 0);
|
|
284
|
+
try {
|
|
285
|
+
let completedItem;
|
|
286
|
+
if ((0, import_isPromise.isPromise)(item)) {
|
|
287
|
+
completedItem = item.then((resolved) => completeValue(exeContext, returnTypeNode, fieldNodes, info, itemPath, resolved));
|
|
288
|
+
} else {
|
|
289
|
+
completedItem = completeValue(exeContext, returnTypeNode, fieldNodes, info, itemPath, item);
|
|
290
|
+
}
|
|
291
|
+
if ((0, import_isPromise.isPromise)(completedItem)) {
|
|
292
|
+
containsPromise = true;
|
|
293
|
+
return completedItem.then(void 0, (rawError) => {
|
|
294
|
+
const error = (0, import_graphql.locatedError)(rawError, fieldNodes, (0, import_Path.pathToArray)(itemPath));
|
|
295
|
+
return handleFieldError(error, returnTypeNode, exeContext);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return completedItem;
|
|
299
|
+
} catch (rawError) {
|
|
300
|
+
const error = (0, import_graphql.locatedError)(rawError, fieldNodes, (0, import_Path.pathToArray)(itemPath));
|
|
301
|
+
return handleFieldError(error, returnTypeNode, exeContext);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
305
|
+
}
|
|
306
|
+
function completeLeafValue(returnType, result) {
|
|
307
|
+
const serializedResult = returnType.serialize(result);
|
|
308
|
+
if (serializedResult === void 0) {
|
|
309
|
+
throw new Error(`Expected a value of type "${(0, import_inspect.inspect)(returnType)}" but received: ${(0, import_inspect.inspect)(result)}`);
|
|
310
|
+
}
|
|
311
|
+
return serializedResult;
|
|
312
|
+
}
|
|
313
|
+
function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result) {
|
|
314
|
+
var _a;
|
|
315
|
+
const resolveTypeFn = (_a = returnType.__resolveType) != null ? _a : exeContext.typeResolver;
|
|
316
|
+
const contextValue = exeContext.contextValue;
|
|
317
|
+
const runtimeTypeName = resolveTypeFn(result, contextValue, info);
|
|
318
|
+
if ((0, import_isPromise.isPromise)(runtimeTypeName)) {
|
|
319
|
+
return runtimeTypeName.then((resolvedRuntimeTypeName) => completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeTypeName, exeContext), fieldNodes, info, path, result));
|
|
320
|
+
}
|
|
321
|
+
return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeTypeName, exeContext), fieldNodes, info, path, result);
|
|
322
|
+
}
|
|
323
|
+
function ensureValidRuntimeType(runtimeTypeName, exeContext) {
|
|
324
|
+
if (typeof runtimeTypeName === "string") {
|
|
325
|
+
const runtimeType = exeContext.resolvers[runtimeTypeName];
|
|
326
|
+
if (!runtimeType) {
|
|
327
|
+
throw new Error("TODO - no such type");
|
|
328
|
+
} else if (runtimeType instanceof import_graphql.GraphQLScalarType || runtimeType instanceof import_graphql.GraphQLEnumType || runtimeType instanceof import_graphql.GraphQLInputObjectType || runtimeType.__resolveType) {
|
|
329
|
+
throw new Error("TODO - invalid runtime type");
|
|
330
|
+
} else {
|
|
331
|
+
return runtimeTypeName;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
throw new Error("TODO - Could not determine runtime type for abstract type");
|
|
335
|
+
}
|
|
336
|
+
function completeObjectValue(exeContext, returnTypeName, fieldNodes, info, path, result) {
|
|
337
|
+
const subFieldNodes = collectSubfields(exeContext, returnTypeName, fieldNodes);
|
|
338
|
+
return executeFields(exeContext, returnTypeName, result, path, subFieldNodes);
|
|
339
|
+
}
|
|
340
|
+
function invalidReturnTypeError(returnType, result, fieldNodes) {
|
|
341
|
+
return new import_graphql.GraphQLError(`Expected value of type "${returnType.name}" but got: ${(0, import_inspect.inspect)(result)}.`, fieldNodes);
|
|
342
|
+
}
|
|
343
|
+
function collectSubfields(exeContext, returnTypeName, fieldNodes) {
|
|
344
|
+
let subFieldNodes = new Map();
|
|
345
|
+
const visitedFragmentNames = new Set();
|
|
346
|
+
for (const node of fieldNodes) {
|
|
347
|
+
if (node.selectionSet) {
|
|
348
|
+
subFieldNodes = (0, import_collectFields.collectFields)(exeContext.resolvers, exeContext.fragments, exeContext.variableValues, returnTypeName, node.selectionSet, subFieldNodes, visitedFragmentNames);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return subFieldNodes;
|
|
352
|
+
}
|
|
353
|
+
const defaultTypeResolver = function(value) {
|
|
354
|
+
if ((0, import_isObjectLike.isObjectLike)(value) && typeof value.__typename === "string") {
|
|
355
|
+
return value.__typename;
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
const defaultFieldResolver = function(source, args, contextValue, info) {
|
|
359
|
+
if ((0, import_isObjectLike.isObjectLike)(source) || typeof source === "function") {
|
|
360
|
+
const property = source[info.fieldName];
|
|
361
|
+
if (typeof property === "function") {
|
|
362
|
+
return source[info.fieldName](args, contextValue, info);
|
|
363
|
+
}
|
|
364
|
+
return property;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
function getOperationRootTypeName(operation) {
|
|
368
|
+
switch (operation.operation) {
|
|
369
|
+
case "query":
|
|
370
|
+
return "Query";
|
|
371
|
+
case "mutation":
|
|
372
|
+
return "Mutation";
|
|
373
|
+
case "subscription":
|
|
374
|
+
return "Subscription";
|
|
375
|
+
}
|
|
376
|
+
}
|