@graphitation/supermassive 2.4.8 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/.eslintcache +1 -1
  2. package/CHANGELOG.md +18 -2
  3. package/README.md +2 -42
  4. package/lib/benchmarks/index.js +3 -3
  5. package/lib/benchmarks/index.js.map +2 -2
  6. package/lib/benchmarks/index.mjs +1 -1
  7. package/lib/benchmarks/index.mjs.map +1 -1
  8. package/lib/collectFields.d.ts +1 -1
  9. package/lib/collectFields.d.ts.map +1 -1
  10. package/lib/collectFields.js.map +1 -1
  11. package/lib/collectFields.mjs.map +1 -1
  12. package/lib/directives.d.ts +1 -1
  13. package/lib/directives.d.ts.map +1 -1
  14. package/lib/directives.js.map +1 -1
  15. package/lib/directives.mjs.map +1 -1
  16. package/lib/executeWithoutSchema.d.ts +1 -1
  17. package/lib/executeWithoutSchema.d.ts.map +1 -1
  18. package/lib/executeWithoutSchema.js.map +1 -1
  19. package/lib/executeWithoutSchema.mjs.map +1 -1
  20. package/lib/hooks/types.d.ts +1 -1
  21. package/lib/hooks/types.d.ts.map +1 -1
  22. package/lib/index.d.ts +6 -3
  23. package/lib/index.d.ts.map +1 -1
  24. package/lib/index.js +3 -4
  25. package/lib/index.js.map +2 -2
  26. package/lib/index.mjs +4 -2
  27. package/lib/index.mjs.map +2 -2
  28. package/lib/jsutils/Maybe.d.ts +1 -1
  29. package/lib/jsutils/Maybe.d.ts.map +1 -1
  30. package/lib/jsutils/ObjMap.d.ts +2 -2
  31. package/lib/jsutils/ObjMap.d.ts.map +1 -1
  32. package/lib/jsutils/PromiseOrValue.d.ts +1 -1
  33. package/lib/jsutils/PromiseOrValue.d.ts.map +1 -1
  34. package/lib/subscribeWithoutSchema.d.ts +1 -1
  35. package/lib/subscribeWithoutSchema.d.ts.map +1 -1
  36. package/lib/subscribeWithoutSchema.js.map +1 -1
  37. package/lib/subscribeWithoutSchema.mjs.map +1 -1
  38. package/lib/types.d.ts +19 -19
  39. package/lib/types.d.ts.map +1 -1
  40. package/lib/types.js.map +1 -1
  41. package/lib/utilities/typeNameFromAST.d.ts +1 -1
  42. package/lib/utilities/typeNameFromAST.d.ts.map +1 -1
  43. package/lib/utilities/typeNameFromAST.js.map +1 -1
  44. package/lib/utilities/typeNameFromAST.mjs.map +1 -1
  45. package/lib/values.d.ts +2 -2
  46. package/lib/values.d.ts.map +1 -1
  47. package/lib/values.js.map +1 -1
  48. package/lib/values.mjs.map +1 -1
  49. package/package.json +5 -6
  50. package/lib/ast/TypedAST.d.ts +0 -367
  51. package/lib/ast/TypedAST.d.ts.map +0 -1
  52. package/lib/ast/TypedAST.js +0 -16
  53. package/lib/ast/TypedAST.js.map +0 -7
  54. package/lib/ast/TypedAST.mjs +0 -0
  55. package/lib/ast/TypedAST.mjs.map +0 -7
  56. package/lib/ast/addTypesToRequestDocument.d.ts +0 -6
  57. package/lib/ast/addTypesToRequestDocument.d.ts.map +0 -1
  58. package/lib/ast/addTypesToRequestDocument.js +0 -161
  59. package/lib/ast/addTypesToRequestDocument.js.map +0 -7
  60. package/lib/ast/addTypesToRequestDocument.mjs +0 -153
  61. package/lib/ast/addTypesToRequestDocument.mjs.map +0 -7
  62. package/lib/transforms/annotateDocumentGraphQLTransform.d.ts +0 -3
  63. package/lib/transforms/annotateDocumentGraphQLTransform.d.ts.map +0 -1
  64. package/lib/transforms/annotateDocumentGraphQLTransform.js +0 -34
  65. package/lib/transforms/annotateDocumentGraphQLTransform.js.map +0 -7
  66. package/lib/transforms/annotateDocumentGraphQLTransform.mjs +0 -17
  67. package/lib/transforms/annotateDocumentGraphQLTransform.mjs.map +0 -7
@@ -1,5 +1,5 @@
1
1
  import type { Maybe } from "./jsutils/Maybe";
2
- import { DocumentNode } from "./ast/TypedAST";
2
+ import { DocumentNode } from "@graphitation/supermassive-ast";
3
3
  import { FunctionFieldResolver, ExecutionWithoutSchemaArgs, Resolvers, ExecutionResult } from "./types";
4
4
  /**
5
5
  * Implements the "Subscribe" algorithm described in the GraphQL specification.
@@ -1 +1 @@
1
- {"version":3,"file":"subscribeWithoutSchema.d.ts","sourceRoot":"","sources":["../src/subscribeWithoutSchema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAQ7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAiB9C,OAAO,EAEL,qBAAqB,EACrB,0BAA0B,EAC1B,SAAS,EACT,eAAe,EAEhB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,cAAc,CAAC,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,eAAe,CAAC,CAmDxE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,YAAY,EACtB,SAAS,CAAC,EAAE,OAAO,EACnB,YAAY,CAAC,EAAE,OAAO,EACtB,cAAc,CAAC,EAAE,KAAK,CAAC;IAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,EAChE,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EAC7B,aAAa,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,GAC7D,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC,CAyCnD"}
1
+ {"version":3,"file":"subscribeWithoutSchema.d.ts","sourceRoot":"","sources":["../src/subscribeWithoutSchema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAQ7C,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAiB9D,OAAO,EAEL,qBAAqB,EACrB,0BAA0B,EAC1B,SAAS,EACT,eAAe,EAEhB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,cAAc,CAAC,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,eAAe,CAAC,CAmDxE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,YAAY,EACtB,SAAS,CAAC,EAAE,OAAO,EACnB,YAAY,CAAC,EAAE,OAAO,EACtB,cAAc,CAAC,EAAE,KAAK,CAAC;IAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,EAChE,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EAC7B,aAAa,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,GAC7D,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC,CAyCnD"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/subscribeWithoutSchema.ts"],
4
- "sourcesContent": ["import { inspect } from \"./jsutils/inspect\";\nimport { isAsyncIterable } from \"./jsutils/isAsyncIterable\";\nimport { addPath, pathToArray } from \"./jsutils/Path\";\nimport type { Maybe } from \"./jsutils/Maybe\";\nimport {\n GraphQLError,\n locatedError,\n Kind,\n ASTNode as GraphQLASTNode,\n TypeNode,\n} from \"graphql\";\nimport { DocumentNode } from \"./ast/TypedAST\";\n\nimport type { ExecutionContext } from \"./executeWithoutSchema\";\nimport {\n assertValidExecutionArguments,\n buildExecutionContext,\n buildResolveInfo,\n executeWithoutSchema,\n getOperationRootTypeName,\n} from \"./executeWithoutSchema\";\nimport { collectFields } from \"./collectFields\";\nimport { getArgumentValues } from \"./values\";\nimport { typeNameFromAST } from \"./utilities/typeNameFromAST\";\nimport { mergeResolvers } from \"./utilities/mergeResolvers\";\n\nimport { mapAsyncIterator } from \"./utilities/mapAsyncIterator\";\n\nimport {\n ObjectTypeResolver,\n FunctionFieldResolver,\n ExecutionWithoutSchemaArgs,\n Resolvers,\n ExecutionResult,\n FieldResolverObject,\n} from \"./types\";\n\n/**\n * Implements the \"Subscribe\" algorithm described in the GraphQL specification.\n *\n * Returns a Promise which resolves to either an AsyncIterator (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with\n * descriptive errors and no data will be returned.\n *\n * If the source stream could not be created due to faulty subscription\n * resolver logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to an AsyncIterator, which\n * yields a stream of ExecutionResults representing the response stream.\n *\n * Accepts either an object with named arguments, or individual arguments.\n */\nexport async function subscribeWithoutSchema(\n args: ExecutionWithoutSchemaArgs,\n): Promise<AsyncGenerator<ExecutionResult, void, void> | ExecutionResult> {\n const {\n resolvers,\n schemaResolvers,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n subscribeFieldResolver,\n } = args;\n\n const combinedResolvers = schemaResolvers\n ? mergeResolvers(resolvers, schemaResolvers)\n : (resolvers as Resolvers);\n\n const resultOrStream = await createSourceEventStream(\n combinedResolvers,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n subscribeFieldResolver,\n );\n\n if (!isAsyncIterable(resultOrStream)) {\n return resultOrStream;\n }\n\n // For each payload yielded from a subscription, map it over the normal\n // GraphQL `execute` function, with `payload` as the rootValue.\n // This implements the \"MapSourceToResponseEvent\" algorithm described in\n // the GraphQL specification. The `execute` function provides the\n // \"ExecuteSubscriptionEvent\" algorithm, as it is nearly identical to the\n // \"ExecuteQuery\" algorithm, for which `execute` is also used.\n const mapSourceToResponse = (payload: unknown) =>\n executeWithoutSchema({\n resolvers,\n schemaResolvers,\n document,\n rootValue: payload,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n });\n\n // Map every source value to a ExecutionResult value as described above.\n return mapAsyncIterator(resultOrStream, mapSourceToResponse);\n}\n\n/**\n * Implements the \"CreateSourceEventStream\" algorithm described in the\n * GraphQL specification, resolving the subscription source event stream.\n *\n * Returns a Promise which resolves to either an AsyncIterable (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with\n * descriptive errors and no data will be returned.\n *\n * If the the source stream could not be created due to faulty subscription\n * resolver logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to the AsyncIterable for the\n * event stream returned by the resolver.\n *\n * A Source Event Stream represents a sequence of events, each of which triggers\n * a GraphQL execution for that event.\n *\n * This may be useful when hosting the stateful subscription service in a\n * different process or machine than the stateless GraphQL execution engine,\n * or otherwise separating these two steps. For more on this, see the\n * \"Supporting Subscriptions at Scale\" information in the GraphQL specification.\n */\nexport async function createSourceEventStream(\n resolvers: Resolvers,\n document: DocumentNode,\n rootValue?: unknown,\n contextValue?: unknown,\n variableValues?: Maybe<{ readonly [variable: string]: unknown }>,\n operationName?: Maybe<string>,\n fieldResolver?: Maybe<FunctionFieldResolver<unknown, unknown>>,\n): Promise<AsyncIterable<unknown> | ExecutionResult> {\n // If arguments are missing or incorrectly typed, this is an internal\n // developer mistake which should throw an early error.\n assertValidExecutionArguments(document, variableValues);\n\n try {\n // If a valid context cannot be created due to incorrect arguments, this will throw an error.\n const exeContext = buildExecutionContext(\n resolvers,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n );\n\n // Return early errors if execution context failed.\n if (!(\"resolvers\" in exeContext)) {\n return { errors: exeContext };\n }\n\n const eventStream = await executeSubscription(exeContext);\n\n // Assert field returned an event stream, otherwise yield an error.\n if (!isAsyncIterable(eventStream)) {\n throw new Error(\n \"Subscription field must return Async Iterable. \" +\n `Received: ${inspect(eventStream)}.`,\n );\n }\n\n return eventStream;\n } catch (error) {\n // If it GraphQLError, report it as an ExecutionResult, containing only errors and no data.\n // Otherwise treat the error as a system-class error and re-throw it.\n if (error instanceof GraphQLError) {\n return { errors: [error] };\n }\n throw error;\n }\n}\n\nasync function executeSubscription(\n exeContext: ExecutionContext,\n): Promise<unknown> {\n const { resolvers, fragments, operation, variableValues, rootValue } =\n exeContext;\n const typeName = getOperationRootTypeName(operation);\n const fields = collectFields(\n resolvers,\n fragments,\n variableValues,\n typeName,\n operation.selectionSet,\n new Map(),\n new Set(),\n );\n\n const [responseName, fieldNodes] = [...fields.entries()][0];\n const fieldName = fieldNodes[0].name.value;\n\n let resolveFn;\n let returnTypeName: string;\n let returnTypeNode: TypeNode;\n if (fieldName === \"__typename\" && !resolveFn) {\n resolveFn = () => typeName;\n returnTypeName = \"String\";\n returnTypeNode = {\n kind: Kind.NAMED_TYPE,\n name: {\n kind: Kind.NAME,\n value: \"String\",\n },\n };\n } else {\n returnTypeNode = fieldNodes[0].__type as TypeNode;\n returnTypeName = typeNameFromAST(returnTypeNode);\n const typeResolvers = exeContext.resolvers[typeName] as\n | ObjectTypeResolver<unknown, unknown, unknown>\n | undefined;\n const fieldResolver = typeResolvers?.[fieldName] as\n | FieldResolverObject<unknown, unknown, unknown, unknown>\n | undefined;\n resolveFn = fieldResolver?.subscribe;\n }\n\n if (!resolveFn) {\n resolveFn = exeContext.fieldResolver;\n }\n\n const path = addPath(undefined, responseName, typeName);\n const info = buildResolveInfo(\n exeContext,\n fieldName,\n fieldNodes,\n typeName,\n returnTypeName,\n returnTypeNode,\n path,\n );\n\n try {\n // Implements the \"ResolveFieldEventStream\" algorithm from GraphQL specification.\n // It differs from \"ResolveFieldValue\" due to providing a different `resolveFn`.\n\n // Build a JS object of arguments from the field.arguments AST, using the\n // variables scope to fulfill unknown variable references.\n const args = getArgumentValues(resolvers, fieldNodes[0], variableValues);\n\n // The resolve function's optional third argument is a context value that\n // is provided to every resolve function within an execution. It is commonly\n // used to represent an authenticated user, or request-specific caches.\n const contextValue = exeContext.contextValue;\n\n // Call the `subscribe()` resolver or the default resolver to produce an\n // AsyncIterable yielding raw payloads.\n const eventStream = await resolveFn(rootValue, args, contextValue, info);\n\n if (eventStream instanceof Error) {\n throw eventStream;\n }\n return eventStream;\n } catch (error) {\n throw locatedError(\n error,\n fieldNodes as ReadonlyArray<GraphQLASTNode>,\n pathToArray(path),\n );\n }\n}\n"],
4
+ "sourcesContent": ["import { inspect } from \"./jsutils/inspect\";\nimport { isAsyncIterable } from \"./jsutils/isAsyncIterable\";\nimport { addPath, pathToArray } from \"./jsutils/Path\";\nimport type { Maybe } from \"./jsutils/Maybe\";\nimport {\n GraphQLError,\n locatedError,\n Kind,\n ASTNode as GraphQLASTNode,\n TypeNode,\n} from \"graphql\";\nimport { DocumentNode } from \"@graphitation/supermassive-ast\";\n\nimport type { ExecutionContext } from \"./executeWithoutSchema\";\nimport {\n assertValidExecutionArguments,\n buildExecutionContext,\n buildResolveInfo,\n executeWithoutSchema,\n getOperationRootTypeName,\n} from \"./executeWithoutSchema\";\nimport { collectFields } from \"./collectFields\";\nimport { getArgumentValues } from \"./values\";\nimport { typeNameFromAST } from \"./utilities/typeNameFromAST\";\nimport { mergeResolvers } from \"./utilities/mergeResolvers\";\n\nimport { mapAsyncIterator } from \"./utilities/mapAsyncIterator\";\n\nimport {\n ObjectTypeResolver,\n FunctionFieldResolver,\n ExecutionWithoutSchemaArgs,\n Resolvers,\n ExecutionResult,\n FieldResolverObject,\n} from \"./types\";\n\n/**\n * Implements the \"Subscribe\" algorithm described in the GraphQL specification.\n *\n * Returns a Promise which resolves to either an AsyncIterator (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with\n * descriptive errors and no data will be returned.\n *\n * If the source stream could not be created due to faulty subscription\n * resolver logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to an AsyncIterator, which\n * yields a stream of ExecutionResults representing the response stream.\n *\n * Accepts either an object with named arguments, or individual arguments.\n */\nexport async function subscribeWithoutSchema(\n args: ExecutionWithoutSchemaArgs,\n): Promise<AsyncGenerator<ExecutionResult, void, void> | ExecutionResult> {\n const {\n resolvers,\n schemaResolvers,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n subscribeFieldResolver,\n } = args;\n\n const combinedResolvers = schemaResolvers\n ? mergeResolvers(resolvers, schemaResolvers)\n : (resolvers as Resolvers);\n\n const resultOrStream = await createSourceEventStream(\n combinedResolvers,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n subscribeFieldResolver,\n );\n\n if (!isAsyncIterable(resultOrStream)) {\n return resultOrStream;\n }\n\n // For each payload yielded from a subscription, map it over the normal\n // GraphQL `execute` function, with `payload` as the rootValue.\n // This implements the \"MapSourceToResponseEvent\" algorithm described in\n // the GraphQL specification. The `execute` function provides the\n // \"ExecuteSubscriptionEvent\" algorithm, as it is nearly identical to the\n // \"ExecuteQuery\" algorithm, for which `execute` is also used.\n const mapSourceToResponse = (payload: unknown) =>\n executeWithoutSchema({\n resolvers,\n schemaResolvers,\n document,\n rootValue: payload,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n });\n\n // Map every source value to a ExecutionResult value as described above.\n return mapAsyncIterator(resultOrStream, mapSourceToResponse);\n}\n\n/**\n * Implements the \"CreateSourceEventStream\" algorithm described in the\n * GraphQL specification, resolving the subscription source event stream.\n *\n * Returns a Promise which resolves to either an AsyncIterable (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with\n * descriptive errors and no data will be returned.\n *\n * If the the source stream could not be created due to faulty subscription\n * resolver logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to the AsyncIterable for the\n * event stream returned by the resolver.\n *\n * A Source Event Stream represents a sequence of events, each of which triggers\n * a GraphQL execution for that event.\n *\n * This may be useful when hosting the stateful subscription service in a\n * different process or machine than the stateless GraphQL execution engine,\n * or otherwise separating these two steps. For more on this, see the\n * \"Supporting Subscriptions at Scale\" information in the GraphQL specification.\n */\nexport async function createSourceEventStream(\n resolvers: Resolvers,\n document: DocumentNode,\n rootValue?: unknown,\n contextValue?: unknown,\n variableValues?: Maybe<{ readonly [variable: string]: unknown }>,\n operationName?: Maybe<string>,\n fieldResolver?: Maybe<FunctionFieldResolver<unknown, unknown>>,\n): Promise<AsyncIterable<unknown> | ExecutionResult> {\n // If arguments are missing or incorrectly typed, this is an internal\n // developer mistake which should throw an early error.\n assertValidExecutionArguments(document, variableValues);\n\n try {\n // If a valid context cannot be created due to incorrect arguments, this will throw an error.\n const exeContext = buildExecutionContext(\n resolvers,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n );\n\n // Return early errors if execution context failed.\n if (!(\"resolvers\" in exeContext)) {\n return { errors: exeContext };\n }\n\n const eventStream = await executeSubscription(exeContext);\n\n // Assert field returned an event stream, otherwise yield an error.\n if (!isAsyncIterable(eventStream)) {\n throw new Error(\n \"Subscription field must return Async Iterable. \" +\n `Received: ${inspect(eventStream)}.`,\n );\n }\n\n return eventStream;\n } catch (error) {\n // If it GraphQLError, report it as an ExecutionResult, containing only errors and no data.\n // Otherwise treat the error as a system-class error and re-throw it.\n if (error instanceof GraphQLError) {\n return { errors: [error] };\n }\n throw error;\n }\n}\n\nasync function executeSubscription(\n exeContext: ExecutionContext,\n): Promise<unknown> {\n const { resolvers, fragments, operation, variableValues, rootValue } =\n exeContext;\n const typeName = getOperationRootTypeName(operation);\n const fields = collectFields(\n resolvers,\n fragments,\n variableValues,\n typeName,\n operation.selectionSet,\n new Map(),\n new Set(),\n );\n\n const [responseName, fieldNodes] = [...fields.entries()][0];\n const fieldName = fieldNodes[0].name.value;\n\n let resolveFn;\n let returnTypeName: string;\n let returnTypeNode: TypeNode;\n if (fieldName === \"__typename\" && !resolveFn) {\n resolveFn = () => typeName;\n returnTypeName = \"String\";\n returnTypeNode = {\n kind: Kind.NAMED_TYPE,\n name: {\n kind: Kind.NAME,\n value: \"String\",\n },\n };\n } else {\n returnTypeNode = fieldNodes[0].__type as TypeNode;\n returnTypeName = typeNameFromAST(returnTypeNode);\n const typeResolvers = exeContext.resolvers[typeName] as\n | ObjectTypeResolver<unknown, unknown, unknown>\n | undefined;\n const fieldResolver = typeResolvers?.[fieldName] as\n | FieldResolverObject<unknown, unknown, unknown, unknown>\n | undefined;\n resolveFn = fieldResolver?.subscribe;\n }\n\n if (!resolveFn) {\n resolveFn = exeContext.fieldResolver;\n }\n\n const path = addPath(undefined, responseName, typeName);\n const info = buildResolveInfo(\n exeContext,\n fieldName,\n fieldNodes,\n typeName,\n returnTypeName,\n returnTypeNode,\n path,\n );\n\n try {\n // Implements the \"ResolveFieldEventStream\" algorithm from GraphQL specification.\n // It differs from \"ResolveFieldValue\" due to providing a different `resolveFn`.\n\n // Build a JS object of arguments from the field.arguments AST, using the\n // variables scope to fulfill unknown variable references.\n const args = getArgumentValues(resolvers, fieldNodes[0], variableValues);\n\n // The resolve function's optional third argument is a context value that\n // is provided to every resolve function within an execution. It is commonly\n // used to represent an authenticated user, or request-specific caches.\n const contextValue = exeContext.contextValue;\n\n // Call the `subscribe()` resolver or the default resolver to produce an\n // AsyncIterable yielding raw payloads.\n const eventStream = await resolveFn(rootValue, args, contextValue, info);\n\n if (eventStream instanceof Error) {\n throw eventStream;\n }\n return eventStream;\n } catch (error) {\n throw locatedError(\n error,\n fieldNodes as ReadonlyArray<GraphQLASTNode>,\n pathToArray(path),\n );\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AACxB,6BAAgC;AAChC,kBAAqC;AAErC,qBAMO;AAIP,kCAMO;AACP,2BAA8B;AAC9B,oBAAkC;AAClC,6BAAgC;AAChC,4BAA+B;AAE/B,8BAAiC;AAgCjC,SAAsB,uBACpB,MACwE;AAAA;AACxE,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI;AAEJ,UAAM,oBAAoB,sBACtB,sCAAe,WAAW,eAAe,IACxC;AAEL,UAAM,iBAAiB,MAAM;AAAA,MAC3B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,QAAI,KAAC,wCAAgB,cAAc,GAAG;AACpC,aAAO;AAAA,IACT;AAQA,UAAM,sBAAsB,CAAC,gBAC3B,kDAAqB;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAGH,eAAO,0CAAiB,gBAAgB,mBAAmB;AAAA,EAC7D;AAAA;AA8BA,SAAsB,wBACpB,WACA,UACA,WACA,cACA,gBACA,eACA,eACmD;AAAA;AAGnD,mEAA8B,UAAU,cAAc;AAEtD,QAAI;AAEF,YAAM,iBAAa;AAAA,QACjB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAGA,UAAI,EAAE,eAAe,aAAa;AAChC,eAAO,EAAE,QAAQ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AAO;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,QAAI;AAMF,YAAM,WAAO,iCAAkB,WAAW,WAAW,CAAC,GAAG,cAAc;AAKvE,YAAM,eAAe,WAAW;AAIhC,YAAM,cAAc,MAAM,UAAU,WAAW,MAAM,cAAc,IAAI;AAEvE,UAAI,uBAAuB,OAAO;AAChC,cAAM;AAAA,MACR;AACA,aAAO;AAAA,IACT,SAAS,OAAP;AACA,gBAAM;AAAA,QACJ;AAAA,QACA;AAAA,YACA,yBAAY,IAAI;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/subscribeWithoutSchema.ts"],
4
- "sourcesContent": ["import { inspect } from \"./jsutils/inspect\";\nimport { isAsyncIterable } from \"./jsutils/isAsyncIterable\";\nimport { addPath, pathToArray } from \"./jsutils/Path\";\nimport type { Maybe } from \"./jsutils/Maybe\";\nimport {\n GraphQLError,\n locatedError,\n Kind,\n ASTNode as GraphQLASTNode,\n TypeNode,\n} from \"graphql\";\nimport { DocumentNode } from \"./ast/TypedAST\";\n\nimport type { ExecutionContext } from \"./executeWithoutSchema\";\nimport {\n assertValidExecutionArguments,\n buildExecutionContext,\n buildResolveInfo,\n executeWithoutSchema,\n getOperationRootTypeName,\n} from \"./executeWithoutSchema\";\nimport { collectFields } from \"./collectFields\";\nimport { getArgumentValues } from \"./values\";\nimport { typeNameFromAST } from \"./utilities/typeNameFromAST\";\nimport { mergeResolvers } from \"./utilities/mergeResolvers\";\n\nimport { mapAsyncIterator } from \"./utilities/mapAsyncIterator\";\n\nimport {\n ObjectTypeResolver,\n FunctionFieldResolver,\n ExecutionWithoutSchemaArgs,\n Resolvers,\n ExecutionResult,\n FieldResolverObject,\n} from \"./types\";\n\n/**\n * Implements the \"Subscribe\" algorithm described in the GraphQL specification.\n *\n * Returns a Promise which resolves to either an AsyncIterator (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with\n * descriptive errors and no data will be returned.\n *\n * If the source stream could not be created due to faulty subscription\n * resolver logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to an AsyncIterator, which\n * yields a stream of ExecutionResults representing the response stream.\n *\n * Accepts either an object with named arguments, or individual arguments.\n */\nexport async function subscribeWithoutSchema(\n args: ExecutionWithoutSchemaArgs,\n): Promise<AsyncGenerator<ExecutionResult, void, void> | ExecutionResult> {\n const {\n resolvers,\n schemaResolvers,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n subscribeFieldResolver,\n } = args;\n\n const combinedResolvers = schemaResolvers\n ? mergeResolvers(resolvers, schemaResolvers)\n : (resolvers as Resolvers);\n\n const resultOrStream = await createSourceEventStream(\n combinedResolvers,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n subscribeFieldResolver,\n );\n\n if (!isAsyncIterable(resultOrStream)) {\n return resultOrStream;\n }\n\n // For each payload yielded from a subscription, map it over the normal\n // GraphQL `execute` function, with `payload` as the rootValue.\n // This implements the \"MapSourceToResponseEvent\" algorithm described in\n // the GraphQL specification. The `execute` function provides the\n // \"ExecuteSubscriptionEvent\" algorithm, as it is nearly identical to the\n // \"ExecuteQuery\" algorithm, for which `execute` is also used.\n const mapSourceToResponse = (payload: unknown) =>\n executeWithoutSchema({\n resolvers,\n schemaResolvers,\n document,\n rootValue: payload,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n });\n\n // Map every source value to a ExecutionResult value as described above.\n return mapAsyncIterator(resultOrStream, mapSourceToResponse);\n}\n\n/**\n * Implements the \"CreateSourceEventStream\" algorithm described in the\n * GraphQL specification, resolving the subscription source event stream.\n *\n * Returns a Promise which resolves to either an AsyncIterable (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with\n * descriptive errors and no data will be returned.\n *\n * If the the source stream could not be created due to faulty subscription\n * resolver logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to the AsyncIterable for the\n * event stream returned by the resolver.\n *\n * A Source Event Stream represents a sequence of events, each of which triggers\n * a GraphQL execution for that event.\n *\n * This may be useful when hosting the stateful subscription service in a\n * different process or machine than the stateless GraphQL execution engine,\n * or otherwise separating these two steps. For more on this, see the\n * \"Supporting Subscriptions at Scale\" information in the GraphQL specification.\n */\nexport async function createSourceEventStream(\n resolvers: Resolvers,\n document: DocumentNode,\n rootValue?: unknown,\n contextValue?: unknown,\n variableValues?: Maybe<{ readonly [variable: string]: unknown }>,\n operationName?: Maybe<string>,\n fieldResolver?: Maybe<FunctionFieldResolver<unknown, unknown>>,\n): Promise<AsyncIterable<unknown> | ExecutionResult> {\n // If arguments are missing or incorrectly typed, this is an internal\n // developer mistake which should throw an early error.\n assertValidExecutionArguments(document, variableValues);\n\n try {\n // If a valid context cannot be created due to incorrect arguments, this will throw an error.\n const exeContext = buildExecutionContext(\n resolvers,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n );\n\n // Return early errors if execution context failed.\n if (!(\"resolvers\" in exeContext)) {\n return { errors: exeContext };\n }\n\n const eventStream = await executeSubscription(exeContext);\n\n // Assert field returned an event stream, otherwise yield an error.\n if (!isAsyncIterable(eventStream)) {\n throw new Error(\n \"Subscription field must return Async Iterable. \" +\n `Received: ${inspect(eventStream)}.`,\n );\n }\n\n return eventStream;\n } catch (error) {\n // If it GraphQLError, report it as an ExecutionResult, containing only errors and no data.\n // Otherwise treat the error as a system-class error and re-throw it.\n if (error instanceof GraphQLError) {\n return { errors: [error] };\n }\n throw error;\n }\n}\n\nasync function executeSubscription(\n exeContext: ExecutionContext,\n): Promise<unknown> {\n const { resolvers, fragments, operation, variableValues, rootValue } =\n exeContext;\n const typeName = getOperationRootTypeName(operation);\n const fields = collectFields(\n resolvers,\n fragments,\n variableValues,\n typeName,\n operation.selectionSet,\n new Map(),\n new Set(),\n );\n\n const [responseName, fieldNodes] = [...fields.entries()][0];\n const fieldName = fieldNodes[0].name.value;\n\n let resolveFn;\n let returnTypeName: string;\n let returnTypeNode: TypeNode;\n if (fieldName === \"__typename\" && !resolveFn) {\n resolveFn = () => typeName;\n returnTypeName = \"String\";\n returnTypeNode = {\n kind: Kind.NAMED_TYPE,\n name: {\n kind: Kind.NAME,\n value: \"String\",\n },\n };\n } else {\n returnTypeNode = fieldNodes[0].__type as TypeNode;\n returnTypeName = typeNameFromAST(returnTypeNode);\n const typeResolvers = exeContext.resolvers[typeName] as\n | ObjectTypeResolver<unknown, unknown, unknown>\n | undefined;\n const fieldResolver = typeResolvers?.[fieldName] as\n | FieldResolverObject<unknown, unknown, unknown, unknown>\n | undefined;\n resolveFn = fieldResolver?.subscribe;\n }\n\n if (!resolveFn) {\n resolveFn = exeContext.fieldResolver;\n }\n\n const path = addPath(undefined, responseName, typeName);\n const info = buildResolveInfo(\n exeContext,\n fieldName,\n fieldNodes,\n typeName,\n returnTypeName,\n returnTypeNode,\n path,\n );\n\n try {\n // Implements the \"ResolveFieldEventStream\" algorithm from GraphQL specification.\n // It differs from \"ResolveFieldValue\" due to providing a different `resolveFn`.\n\n // Build a JS object of arguments from the field.arguments AST, using the\n // variables scope to fulfill unknown variable references.\n const args = getArgumentValues(resolvers, fieldNodes[0], variableValues);\n\n // The resolve function's optional third argument is a context value that\n // is provided to every resolve function within an execution. It is commonly\n // used to represent an authenticated user, or request-specific caches.\n const contextValue = exeContext.contextValue;\n\n // Call the `subscribe()` resolver or the default resolver to produce an\n // AsyncIterable yielding raw payloads.\n const eventStream = await resolveFn(rootValue, args, contextValue, info);\n\n if (eventStream instanceof Error) {\n throw eventStream;\n }\n return eventStream;\n } catch (error) {\n throw locatedError(\n error,\n fieldNodes as ReadonlyArray<GraphQLASTNode>,\n pathToArray(path),\n );\n }\n}\n"],
4
+ "sourcesContent": ["import { inspect } from \"./jsutils/inspect\";\nimport { isAsyncIterable } from \"./jsutils/isAsyncIterable\";\nimport { addPath, pathToArray } from \"./jsutils/Path\";\nimport type { Maybe } from \"./jsutils/Maybe\";\nimport {\n GraphQLError,\n locatedError,\n Kind,\n ASTNode as GraphQLASTNode,\n TypeNode,\n} from \"graphql\";\nimport { DocumentNode } from \"@graphitation/supermassive-ast\";\n\nimport type { ExecutionContext } from \"./executeWithoutSchema\";\nimport {\n assertValidExecutionArguments,\n buildExecutionContext,\n buildResolveInfo,\n executeWithoutSchema,\n getOperationRootTypeName,\n} from \"./executeWithoutSchema\";\nimport { collectFields } from \"./collectFields\";\nimport { getArgumentValues } from \"./values\";\nimport { typeNameFromAST } from \"./utilities/typeNameFromAST\";\nimport { mergeResolvers } from \"./utilities/mergeResolvers\";\n\nimport { mapAsyncIterator } from \"./utilities/mapAsyncIterator\";\n\nimport {\n ObjectTypeResolver,\n FunctionFieldResolver,\n ExecutionWithoutSchemaArgs,\n Resolvers,\n ExecutionResult,\n FieldResolverObject,\n} from \"./types\";\n\n/**\n * Implements the \"Subscribe\" algorithm described in the GraphQL specification.\n *\n * Returns a Promise which resolves to either an AsyncIterator (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with\n * descriptive errors and no data will be returned.\n *\n * If the source stream could not be created due to faulty subscription\n * resolver logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to an AsyncIterator, which\n * yields a stream of ExecutionResults representing the response stream.\n *\n * Accepts either an object with named arguments, or individual arguments.\n */\nexport async function subscribeWithoutSchema(\n args: ExecutionWithoutSchemaArgs,\n): Promise<AsyncGenerator<ExecutionResult, void, void> | ExecutionResult> {\n const {\n resolvers,\n schemaResolvers,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n subscribeFieldResolver,\n } = args;\n\n const combinedResolvers = schemaResolvers\n ? mergeResolvers(resolvers, schemaResolvers)\n : (resolvers as Resolvers);\n\n const resultOrStream = await createSourceEventStream(\n combinedResolvers,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n subscribeFieldResolver,\n );\n\n if (!isAsyncIterable(resultOrStream)) {\n return resultOrStream;\n }\n\n // For each payload yielded from a subscription, map it over the normal\n // GraphQL `execute` function, with `payload` as the rootValue.\n // This implements the \"MapSourceToResponseEvent\" algorithm described in\n // the GraphQL specification. The `execute` function provides the\n // \"ExecuteSubscriptionEvent\" algorithm, as it is nearly identical to the\n // \"ExecuteQuery\" algorithm, for which `execute` is also used.\n const mapSourceToResponse = (payload: unknown) =>\n executeWithoutSchema({\n resolvers,\n schemaResolvers,\n document,\n rootValue: payload,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n });\n\n // Map every source value to a ExecutionResult value as described above.\n return mapAsyncIterator(resultOrStream, mapSourceToResponse);\n}\n\n/**\n * Implements the \"CreateSourceEventStream\" algorithm described in the\n * GraphQL specification, resolving the subscription source event stream.\n *\n * Returns a Promise which resolves to either an AsyncIterable (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with\n * descriptive errors and no data will be returned.\n *\n * If the the source stream could not be created due to faulty subscription\n * resolver logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to the AsyncIterable for the\n * event stream returned by the resolver.\n *\n * A Source Event Stream represents a sequence of events, each of which triggers\n * a GraphQL execution for that event.\n *\n * This may be useful when hosting the stateful subscription service in a\n * different process or machine than the stateless GraphQL execution engine,\n * or otherwise separating these two steps. For more on this, see the\n * \"Supporting Subscriptions at Scale\" information in the GraphQL specification.\n */\nexport async function createSourceEventStream(\n resolvers: Resolvers,\n document: DocumentNode,\n rootValue?: unknown,\n contextValue?: unknown,\n variableValues?: Maybe<{ readonly [variable: string]: unknown }>,\n operationName?: Maybe<string>,\n fieldResolver?: Maybe<FunctionFieldResolver<unknown, unknown>>,\n): Promise<AsyncIterable<unknown> | ExecutionResult> {\n // If arguments are missing or incorrectly typed, this is an internal\n // developer mistake which should throw an early error.\n assertValidExecutionArguments(document, variableValues);\n\n try {\n // If a valid context cannot be created due to incorrect arguments, this will throw an error.\n const exeContext = buildExecutionContext(\n resolvers,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n );\n\n // Return early errors if execution context failed.\n if (!(\"resolvers\" in exeContext)) {\n return { errors: exeContext };\n }\n\n const eventStream = await executeSubscription(exeContext);\n\n // Assert field returned an event stream, otherwise yield an error.\n if (!isAsyncIterable(eventStream)) {\n throw new Error(\n \"Subscription field must return Async Iterable. \" +\n `Received: ${inspect(eventStream)}.`,\n );\n }\n\n return eventStream;\n } catch (error) {\n // If it GraphQLError, report it as an ExecutionResult, containing only errors and no data.\n // Otherwise treat the error as a system-class error and re-throw it.\n if (error instanceof GraphQLError) {\n return { errors: [error] };\n }\n throw error;\n }\n}\n\nasync function executeSubscription(\n exeContext: ExecutionContext,\n): Promise<unknown> {\n const { resolvers, fragments, operation, variableValues, rootValue } =\n exeContext;\n const typeName = getOperationRootTypeName(operation);\n const fields = collectFields(\n resolvers,\n fragments,\n variableValues,\n typeName,\n operation.selectionSet,\n new Map(),\n new Set(),\n );\n\n const [responseName, fieldNodes] = [...fields.entries()][0];\n const fieldName = fieldNodes[0].name.value;\n\n let resolveFn;\n let returnTypeName: string;\n let returnTypeNode: TypeNode;\n if (fieldName === \"__typename\" && !resolveFn) {\n resolveFn = () => typeName;\n returnTypeName = \"String\";\n returnTypeNode = {\n kind: Kind.NAMED_TYPE,\n name: {\n kind: Kind.NAME,\n value: \"String\",\n },\n };\n } else {\n returnTypeNode = fieldNodes[0].__type as TypeNode;\n returnTypeName = typeNameFromAST(returnTypeNode);\n const typeResolvers = exeContext.resolvers[typeName] as\n | ObjectTypeResolver<unknown, unknown, unknown>\n | undefined;\n const fieldResolver = typeResolvers?.[fieldName] as\n | FieldResolverObject<unknown, unknown, unknown, unknown>\n | undefined;\n resolveFn = fieldResolver?.subscribe;\n }\n\n if (!resolveFn) {\n resolveFn = exeContext.fieldResolver;\n }\n\n const path = addPath(undefined, responseName, typeName);\n const info = buildResolveInfo(\n exeContext,\n fieldName,\n fieldNodes,\n typeName,\n returnTypeName,\n returnTypeNode,\n path,\n );\n\n try {\n // Implements the \"ResolveFieldEventStream\" algorithm from GraphQL specification.\n // It differs from \"ResolveFieldValue\" due to providing a different `resolveFn`.\n\n // Build a JS object of arguments from the field.arguments AST, using the\n // variables scope to fulfill unknown variable references.\n const args = getArgumentValues(resolvers, fieldNodes[0], variableValues);\n\n // The resolve function's optional third argument is a context value that\n // is provided to every resolve function within an execution. It is commonly\n // used to represent an authenticated user, or request-specific caches.\n const contextValue = exeContext.contextValue;\n\n // Call the `subscribe()` resolver or the default resolver to produce an\n // AsyncIterable yielding raw payloads.\n const eventStream = await resolveFn(rootValue, args, contextValue, info);\n\n if (eventStream instanceof Error) {\n throw eventStream;\n }\n return eventStream;\n } catch (error) {\n throw locatedError(\n error,\n fieldNodes as ReadonlyArray<GraphQLASTNode>,\n pathToArray(path),\n );\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,SAAS,SAAS,mBAAmB;AAErC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAIP;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,MAAM,UAAU,WAAW,MAAM,cAAc,IAAI;AAEvE,UAAI,uBAAuB,OAAO;AAChC,cAAM;AAAA,MACR;AACA,aAAO;AAAA,IACT,SAAS,OAAP;AACA,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA,YAAY,IAAI;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAAA;",
6
6
  "names": []
7
7
  }
package/lib/types.d.ts CHANGED
@@ -1,45 +1,45 @@
1
1
  import { GraphQLEnumType, GraphQLError, GraphQLFormattedError, GraphQLInputObjectType, GraphQLScalarType, DocumentNode as UntypedDocumentNode } from "graphql";
2
2
  import { Maybe } from "./jsutils/Maybe";
3
3
  import { PromiseOrValue } from "./jsutils/PromiseOrValue";
4
- import { DocumentNode, FieldNode, FragmentDefinitionNode, OperationDefinitionNode, TypeNode } from "./ast/TypedAST";
4
+ import { DocumentNode, FieldNode, FragmentDefinitionNode, OperationDefinitionNode, TypeNode } from "@graphitation/supermassive-ast";
5
5
  import { ObjMap } from "./jsutils/ObjMap";
6
6
  import { Path } from "./jsutils/Path";
7
7
  import { ExecutionHooks } from "./hooks/types";
8
- export declare type ScalarTypeResolver = GraphQLScalarType;
9
- export declare type EnumTypeResolver = GraphQLEnumType;
10
- export declare type FunctionFieldResolver<TSource, TContext, TArgs = Record<string, unknown>, TReturn = unknown> = (source: TSource, args: TArgs, context: TContext, info: ResolveInfo) => TReturn;
11
- export declare type FieldResolver<TSource, TContext, TArgs = Record<string, unknown>, TReturn = unknown> = FunctionFieldResolver<TSource, TContext, TArgs, TReturn> | FieldResolverObject<TSource, TContext, TArgs, TReturn>;
12
- export declare type FieldResolverObject<TSource, TContext, TArgs = Record<string, unknown>, TReturn = unknown> = {
8
+ export type ScalarTypeResolver = GraphQLScalarType;
9
+ export type EnumTypeResolver = GraphQLEnumType;
10
+ export type FunctionFieldResolver<TSource, TContext, TArgs = Record<string, unknown>, TReturn = unknown> = (source: TSource, args: TArgs, context: TContext, info: ResolveInfo) => TReturn;
11
+ export type FieldResolver<TSource, TContext, TArgs = Record<string, unknown>, TReturn = unknown> = FunctionFieldResolver<TSource, TContext, TArgs, TReturn> | FieldResolverObject<TSource, TContext, TArgs, TReturn>;
12
+ export type FieldResolverObject<TSource, TContext, TArgs = Record<string, unknown>, TReturn = unknown> = {
13
13
  subscribe?: FunctionFieldResolver<TSource, TContext, TArgs, TReturn>;
14
14
  resolve?: FunctionFieldResolver<TSource, TContext, TArgs, TReturn>;
15
15
  };
16
- export declare type TypeResolver<TSource, TContext> = (value: TSource, context: TContext, info: ResolveInfo) => PromiseOrValue<Maybe<string>>;
17
- export declare type ObjectTypeResolver<TSource = unknown, TContext = unknown, TArgs = unknown> = {
16
+ export type TypeResolver<TSource, TContext> = (value: TSource, context: TContext, info: ResolveInfo) => PromiseOrValue<Maybe<string>>;
17
+ export type ObjectTypeResolver<TSource = unknown, TContext = unknown, TArgs = unknown> = {
18
18
  [key: string]: FieldResolver<TSource, TContext, TArgs>;
19
19
  };
20
- export declare type InterfaceTypeResolver<TSource = unknown, TContext = unknown, TArgs = unknown> = {
20
+ export type InterfaceTypeResolver<TSource = unknown, TContext = unknown, TArgs = unknown> = {
21
21
  __implementedBy: string[];
22
22
  [key: string]: FieldResolver<TSource, TContext, TArgs> | string[] | undefined;
23
23
  } & {
24
24
  __resolveType?: TypeResolver<unknown, unknown>;
25
25
  };
26
- export declare type UnionTypeResolver = {
26
+ export type UnionTypeResolver = {
27
27
  __resolveType?: TypeResolver<unknown, unknown>;
28
28
  __types: string[];
29
29
  };
30
- export declare type UserInterfaceTypeResolver<TSource = unknown, TContext = unknown, TArgs = unknown> = {
30
+ export type UserInterfaceTypeResolver<TSource = unknown, TContext = unknown, TArgs = unknown> = {
31
31
  [key: string]: FieldResolver<TSource, TContext, TArgs>;
32
32
  } & {
33
33
  __resolveType?: TypeResolver<unknown, unknown>;
34
34
  };
35
- export declare type UserUnionTypeResolver = {
35
+ export type UserUnionTypeResolver = {
36
36
  __resolveType?: TypeResolver<unknown, unknown>;
37
37
  };
38
- export declare type InputObjectTypeResolver = GraphQLInputObjectType;
39
- export declare type UserResolver<TSource, TContext> = ObjectTypeResolver<TSource, TContext> | UserInterfaceTypeResolver<TSource, TContext> | UserUnionTypeResolver | ScalarTypeResolver | EnumTypeResolver | InputObjectTypeResolver;
40
- export declare type Resolver<TSource, TContext> = ObjectTypeResolver<TSource, TContext> | InterfaceTypeResolver<TSource, TContext> | UnionTypeResolver | ScalarTypeResolver | EnumTypeResolver | InputObjectTypeResolver;
41
- export declare type Resolvers<TSource = unknown, TContext = unknown> = Record<string, Resolver<TSource, TContext>>;
42
- export declare type UserResolvers<TSource = unknown, TContext = unknown> = Record<string, UserResolver<TSource, TContext>>;
38
+ export type InputObjectTypeResolver = GraphQLInputObjectType;
39
+ export type UserResolver<TSource, TContext> = ObjectTypeResolver<TSource, TContext> | UserInterfaceTypeResolver<TSource, TContext> | UserUnionTypeResolver | ScalarTypeResolver | EnumTypeResolver | InputObjectTypeResolver;
40
+ export type Resolver<TSource, TContext> = ObjectTypeResolver<TSource, TContext> | InterfaceTypeResolver<TSource, TContext> | UnionTypeResolver | ScalarTypeResolver | EnumTypeResolver | InputObjectTypeResolver;
41
+ export type Resolvers<TSource = unknown, TContext = unknown> = Record<string, Resolver<TSource, TContext>>;
42
+ export type UserResolvers<TSource = unknown, TContext = unknown> = Record<string, UserResolver<TSource, TContext>>;
43
43
  export interface ResolveInfo {
44
44
  fieldName: string;
45
45
  fieldNodes: Array<FieldNode>;
@@ -84,11 +84,11 @@ export interface CommonExecutionArgs {
84
84
  subscribeFieldResolver?: Maybe<FunctionFieldResolver<unknown, unknown>>;
85
85
  fieldExecutionHooks?: ExecutionHooks;
86
86
  }
87
- export declare type ExecutionWithoutSchemaArgs = CommonExecutionArgs & {
87
+ export type ExecutionWithoutSchemaArgs = CommonExecutionArgs & {
88
88
  document: DocumentNode;
89
89
  schemaResolvers?: Resolvers;
90
90
  };
91
- export declare type ExecutionWithSchemaArgs = CommonExecutionArgs & {
91
+ export type ExecutionWithSchemaArgs = CommonExecutionArgs & {
92
92
  document: UntypedDocumentNode;
93
93
  typeDefs: UntypedDocumentNode;
94
94
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,IAAI,mBAAmB,EACpC,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EACvB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,oBAAY,kBAAkB,GAAG,iBAAiB,CAAC;AACnD,oBAAY,gBAAgB,GAAG,eAAe,CAAC;AAC/C,oBAAY,qBAAqB,CAC/B,OAAO,EACP,QAAQ,EACR,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,GAAG,OAAO,IACf,CACF,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,WAAW,KACd,OAAO,CAAC;AAEb,oBAAY,aAAa,CACvB,OAAO,EACP,QAAQ,EACR,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,GAAG,OAAO,IAEf,qBAAqB,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,GACxD,mBAAmB,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAA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AU,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,aAAa,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,KAAK,CAAC;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,CAAC;IACxD,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,aAAa,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/D,YAAY,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACrD,sBAAsB,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACxE,mBAAmB,CAAC,EAAE,cAAc,CAAC;CACtC;AACD,MAAM,MAAM,0BAA0B,GAAG,mBAAmB,GAAG;IAC7D,QAAQ,EAAE,YAAY,CAAC;IACvB,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,GAAG;IAC1D,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,QAAQ,EAAE,mBAAmB,CAAC;CAC/B,CAAC"}
package/lib/types.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/types.ts"],
4
- "sourcesContent": ["import {\n GraphQLEnumType,\n GraphQLError,\n GraphQLFormattedError,\n GraphQLInputObjectType,\n GraphQLScalarType,\n DocumentNode as UntypedDocumentNode,\n} from \"graphql\";\nimport { Maybe } from \"./jsutils/Maybe\";\nimport { PromiseOrValue } from \"./jsutils/PromiseOrValue\";\nimport {\n DocumentNode,\n FieldNode,\n FragmentDefinitionNode,\n OperationDefinitionNode,\n TypeNode,\n} from \"./ast/TypedAST\";\nimport { ObjMap } from \"./jsutils/ObjMap\";\nimport { Path } from \"./jsutils/Path\";\nimport { ExecutionHooks } from \"./hooks/types\";\n\nexport type ScalarTypeResolver = GraphQLScalarType;\nexport type EnumTypeResolver = GraphQLEnumType; // TODO Record<string, unknown>;\nexport type FunctionFieldResolver<\n TSource,\n TContext,\n TArgs = Record<string, unknown>,\n TReturn = unknown,\n> = (\n source: TSource,\n args: TArgs,\n context: TContext,\n info: ResolveInfo,\n) => TReturn;\n\nexport type FieldResolver<\n TSource,\n TContext,\n TArgs = Record<string, unknown>,\n TReturn = unknown,\n> =\n | FunctionFieldResolver<TSource, TContext, TArgs, TReturn>\n | FieldResolverObject<TSource, TContext, TArgs, TReturn>;\n\nexport type FieldResolverObject<\n TSource,\n TContext,\n TArgs = Record<string, unknown>,\n TReturn = unknown,\n> = {\n subscribe?: FunctionFieldResolver<TSource, TContext, TArgs, TReturn>;\n resolve?: FunctionFieldResolver<TSource, TContext, TArgs, TReturn>;\n};\n\nexport type TypeResolver<TSource, TContext> = (\n value: TSource,\n context: TContext,\n info: ResolveInfo,\n) => PromiseOrValue<Maybe<string>>;\n\nexport type ObjectTypeResolver<\n TSource = unknown,\n TContext = unknown,\n TArgs = unknown,\n> = {\n [key: string]: FieldResolver<TSource, TContext, TArgs>;\n};\n\nexport type InterfaceTypeResolver<\n TSource = unknown,\n TContext = unknown,\n TArgs = unknown,\n> = {\n __implementedBy: string[];\n [key: string]: FieldResolver<TSource, TContext, TArgs> | string[] | undefined;\n} & {\n __resolveType?: TypeResolver<unknown, unknown>;\n};\nexport type UnionTypeResolver = {\n __resolveType?: TypeResolver<unknown, unknown>;\n __types: string[];\n};\n\nexport type UserInterfaceTypeResolver<\n TSource = unknown,\n TContext = unknown,\n TArgs = unknown,\n> = {\n [key: string]: FieldResolver<TSource, TContext, TArgs>;\n} & {\n __resolveType?: TypeResolver<unknown, unknown>;\n};\n\nexport type UserUnionTypeResolver = {\n __resolveType?: TypeResolver<unknown, unknown>;\n};\n\nexport type InputObjectTypeResolver = GraphQLInputObjectType;\n\nexport type UserResolver<TSource, TContext> =\n | ObjectTypeResolver<TSource, TContext>\n | UserInterfaceTypeResolver<TSource, TContext>\n | UserUnionTypeResolver\n | ScalarTypeResolver\n | EnumTypeResolver\n | InputObjectTypeResolver;\n\nexport type Resolver<TSource, TContext> =\n | ObjectTypeResolver<TSource, TContext>\n | InterfaceTypeResolver<TSource, TContext>\n | UnionTypeResolver\n | ScalarTypeResolver\n | EnumTypeResolver\n | InputObjectTypeResolver;\n\nexport type Resolvers<TSource = unknown, TContext = unknown> = Record<\n string,\n Resolver<TSource, TContext>\n>;\n\nexport type UserResolvers<TSource = unknown, TContext = unknown> = Record<\n string,\n UserResolver<TSource, TContext>\n>;\n\nexport interface ResolveInfo {\n fieldName: string;\n fieldNodes: Array<FieldNode>;\n returnTypeName: string;\n parentTypeName: string;\n returnTypeNode: TypeNode;\n // readonly returnType: GraphQLOutputType;\n // readonly parentType: GraphQLObjectType;\n path: Path;\n // readonly schema: GraphQLSchema;\n fragments: ObjMap<FragmentDefinitionNode>;\n rootValue: unknown;\n operation: OperationDefinitionNode;\n variableValues: { [variable: string]: unknown };\n}\n\n/**\n * The result of GraphQL execution.\n *\n * - `errors` is included when any errors occurred as a non-empty array.\n * - `data` is the result of a successful execution of the query.\n * - `extensions` is reserved for adding non-standard properties.\n */\nexport interface ExecutionResult<\n TData = ObjMap<unknown>,\n TExtensions = ObjMap<unknown>,\n> {\n errors?: Array<GraphQLError>;\n data?: TData | null;\n extensions?: TExtensions;\n}\n\nexport interface FormattedExecutionResult<\n TData = ObjMap<unknown>,\n TExtensions = ObjMap<unknown>,\n> {\n errors?: Array<GraphQLFormattedError>;\n data?: TData | null;\n extensions?: TExtensions;\n}\n\nexport interface CommonExecutionArgs {\n resolvers: UserResolvers;\n rootValue?: unknown;\n contextValue?: unknown;\n variableValues?: Maybe<{ [variable: string]: unknown }>;\n operationName?: Maybe<string>;\n fieldResolver?: Maybe<FunctionFieldResolver<unknown, unknown>>;\n typeResolver?: Maybe<TypeResolver<unknown, unknown>>;\n subscribeFieldResolver?: Maybe<FunctionFieldResolver<unknown, unknown>>;\n fieldExecutionHooks?: ExecutionHooks;\n}\nexport type ExecutionWithoutSchemaArgs = CommonExecutionArgs & {\n document: DocumentNode;\n schemaResolvers?: Resolvers;\n};\n\nexport type ExecutionWithSchemaArgs = CommonExecutionArgs & {\n document: UntypedDocumentNode;\n typeDefs: UntypedDocumentNode;\n};\n"],
4
+ "sourcesContent": ["import {\n GraphQLEnumType,\n GraphQLError,\n GraphQLFormattedError,\n GraphQLInputObjectType,\n GraphQLScalarType,\n DocumentNode as UntypedDocumentNode,\n} from \"graphql\";\nimport { Maybe } from \"./jsutils/Maybe\";\nimport { PromiseOrValue } from \"./jsutils/PromiseOrValue\";\nimport {\n DocumentNode,\n FieldNode,\n FragmentDefinitionNode,\n OperationDefinitionNode,\n TypeNode,\n} from \"@graphitation/supermassive-ast\";\nimport { ObjMap } from \"./jsutils/ObjMap\";\nimport { Path } from \"./jsutils/Path\";\nimport { ExecutionHooks } from \"./hooks/types\";\n\nexport type ScalarTypeResolver = GraphQLScalarType;\nexport type EnumTypeResolver = GraphQLEnumType; // TODO Record<string, unknown>;\nexport type FunctionFieldResolver<\n TSource,\n TContext,\n TArgs = Record<string, unknown>,\n TReturn = unknown,\n> = (\n source: TSource,\n args: TArgs,\n context: TContext,\n info: ResolveInfo,\n) => TReturn;\n\nexport type FieldResolver<\n TSource,\n TContext,\n TArgs = Record<string, unknown>,\n TReturn = unknown,\n> =\n | FunctionFieldResolver<TSource, TContext, TArgs, TReturn>\n | FieldResolverObject<TSource, TContext, TArgs, TReturn>;\n\nexport type FieldResolverObject<\n TSource,\n TContext,\n TArgs = Record<string, unknown>,\n TReturn = unknown,\n> = {\n subscribe?: FunctionFieldResolver<TSource, TContext, TArgs, TReturn>;\n resolve?: FunctionFieldResolver<TSource, TContext, TArgs, TReturn>;\n};\n\nexport type TypeResolver<TSource, TContext> = (\n value: TSource,\n context: TContext,\n info: ResolveInfo,\n) => PromiseOrValue<Maybe<string>>;\n\nexport type ObjectTypeResolver<\n TSource = unknown,\n TContext = unknown,\n TArgs = unknown,\n> = {\n [key: string]: FieldResolver<TSource, TContext, TArgs>;\n};\n\nexport type InterfaceTypeResolver<\n TSource = unknown,\n TContext = unknown,\n TArgs = unknown,\n> = {\n __implementedBy: string[];\n [key: string]: FieldResolver<TSource, TContext, TArgs> | string[] | undefined;\n} & {\n __resolveType?: TypeResolver<unknown, unknown>;\n};\nexport type UnionTypeResolver = {\n __resolveType?: TypeResolver<unknown, unknown>;\n __types: string[];\n};\n\nexport type UserInterfaceTypeResolver<\n TSource = unknown,\n TContext = unknown,\n TArgs = unknown,\n> = {\n [key: string]: FieldResolver<TSource, TContext, TArgs>;\n} & {\n __resolveType?: TypeResolver<unknown, unknown>;\n};\n\nexport type UserUnionTypeResolver = {\n __resolveType?: TypeResolver<unknown, unknown>;\n};\n\nexport type InputObjectTypeResolver = GraphQLInputObjectType;\n\nexport type UserResolver<TSource, TContext> =\n | ObjectTypeResolver<TSource, TContext>\n | UserInterfaceTypeResolver<TSource, TContext>\n | UserUnionTypeResolver\n | ScalarTypeResolver\n | EnumTypeResolver\n | InputObjectTypeResolver;\n\nexport type Resolver<TSource, TContext> =\n | ObjectTypeResolver<TSource, TContext>\n | InterfaceTypeResolver<TSource, TContext>\n | UnionTypeResolver\n | ScalarTypeResolver\n | EnumTypeResolver\n | InputObjectTypeResolver;\n\nexport type Resolvers<TSource = unknown, TContext = unknown> = Record<\n string,\n Resolver<TSource, TContext>\n>;\n\nexport type UserResolvers<TSource = unknown, TContext = unknown> = Record<\n string,\n UserResolver<TSource, TContext>\n>;\n\nexport interface ResolveInfo {\n fieldName: string;\n fieldNodes: Array<FieldNode>;\n returnTypeName: string;\n parentTypeName: string;\n returnTypeNode: TypeNode;\n // readonly returnType: GraphQLOutputType;\n // readonly parentType: GraphQLObjectType;\n path: Path;\n // readonly schema: GraphQLSchema;\n fragments: ObjMap<FragmentDefinitionNode>;\n rootValue: unknown;\n operation: OperationDefinitionNode;\n variableValues: { [variable: string]: unknown };\n}\n\n/**\n * The result of GraphQL execution.\n *\n * - `errors` is included when any errors occurred as a non-empty array.\n * - `data` is the result of a successful execution of the query.\n * - `extensions` is reserved for adding non-standard properties.\n */\nexport interface ExecutionResult<\n TData = ObjMap<unknown>,\n TExtensions = ObjMap<unknown>,\n> {\n errors?: Array<GraphQLError>;\n data?: TData | null;\n extensions?: TExtensions;\n}\n\nexport interface FormattedExecutionResult<\n TData = ObjMap<unknown>,\n TExtensions = ObjMap<unknown>,\n> {\n errors?: Array<GraphQLFormattedError>;\n data?: TData | null;\n extensions?: TExtensions;\n}\n\nexport interface CommonExecutionArgs {\n resolvers: UserResolvers;\n rootValue?: unknown;\n contextValue?: unknown;\n variableValues?: Maybe<{ [variable: string]: unknown }>;\n operationName?: Maybe<string>;\n fieldResolver?: Maybe<FunctionFieldResolver<unknown, unknown>>;\n typeResolver?: Maybe<TypeResolver<unknown, unknown>>;\n subscribeFieldResolver?: Maybe<FunctionFieldResolver<unknown, unknown>>;\n fieldExecutionHooks?: ExecutionHooks;\n}\nexport type ExecutionWithoutSchemaArgs = CommonExecutionArgs & {\n document: DocumentNode;\n schemaResolvers?: Resolvers;\n};\n\nexport type ExecutionWithSchemaArgs = CommonExecutionArgs & {\n document: UntypedDocumentNode;\n typeDefs: UntypedDocumentNode;\n};\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,3 @@
1
- import { TypeNode } from "../ast/TypedAST";
1
+ import { TypeNode } from "@graphitation/supermassive-ast";
2
2
  export declare function typeNameFromAST(typeAst: TypeNode): string;
3
3
  //# sourceMappingURL=typeNameFromAST.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeNameFromAST.d.ts","sourceRoot":"","sources":["../../src/utilities/typeNameFromAST.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,wBAAgB,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,MAAM,CAMzD"}
1
+ {"version":3,"file":"typeNameFromAST.d.ts","sourceRoot":"","sources":["../../src/utilities/typeNameFromAST.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAE1D,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 } from \"graphql\";\nimport { TypeNode } from \"../ast/TypedAST\";\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"],
4
+ "sourcesContent": ["import { Kind } from \"graphql\";\nimport { TypeNode } from \"@graphitation/supermassive-ast\";\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
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAqB;AAGd,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 } from \"graphql\";\nimport { TypeNode } from \"../ast/TypedAST\";\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"],
4
+ "sourcesContent": ["import { Kind } from \"graphql\";\nimport { TypeNode } from \"@graphitation/supermassive-ast\";\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
5
  "mappings": ";AAAA,SAAS,YAAY;AAGd,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
  }
package/lib/values.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { GraphQLError, GraphQLScalarType } from "graphql";
2
- import { DirectiveNode, FieldNode, VariableDefinitionNode } from "./ast/TypedAST";
2
+ import { DirectiveNode, FieldNode, VariableDefinitionNode } from "@graphitation/supermassive-ast";
3
3
  import type { Maybe } from "./jsutils/Maybe";
4
4
  import type { ObjMap } from "./jsutils/ObjMap";
5
5
  import { Resolvers } from "./types";
6
6
  import { GraphQLDirective } from "./directives";
7
- declare type CoercedVariableValues = {
7
+ type CoercedVariableValues = {
8
8
  errors: Array<GraphQLError>;
9
9
  coerced?: never;
10
10
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../src/values.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAMZ,iBAAiB,EAYlB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,aA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EAAE,SAAS,EACpB,IAAI,EAAE,SAAS,GAAG,aAAa,EAC/B,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GACtC;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CA8DjC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,gBAAgB,EAC9B,IAAI,EAAE;IAAE,UAAU,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAA;CAAE,EACnD,SAAS,EAAE,SAAS,EACpB,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GACtC,SAAS,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAS7C;AAMD,eAAO,MAAM,gBAAgB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAA;CAMhE,CAAC"}
package/lib/values.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/values.ts"],
4
- "sourcesContent": ["import {\n ArgumentNode as GraphQLArgumentNode,\n GraphQLBoolean,\n GraphQLError,\n GraphQLFloat,\n GraphQLID,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLScalarType,\n GraphQLString,\n GraphQLType,\n isInputType,\n isNonNullType,\n Kind,\n print,\n TypeNode as GraphQLTypeNode,\n ValueNode as GraphQLValueNode,\n VariableDefinitionNode as GraphQLVariableDefinitionNode,\n valueFromAST,\n coerceInputValue,\n} from \"graphql\";\nimport {\n DirectiveNode,\n FieldNode,\n TypeNode,\n VariableDefinitionNode,\n} from \"./ast/TypedAST\";\nimport { inspect } from \"./jsutils/inspect\";\nimport type { Maybe } from \"./jsutils/Maybe\";\nimport type { ObjMap } from \"./jsutils/ObjMap\";\nimport { printPathArray } from \"./jsutils/printPathArray\";\nimport { Resolvers } from \"./types\";\nimport { GraphQLDirective } from \"./directives\";\n\ntype CoercedVariableValues =\n | { errors: Array<GraphQLError>; coerced?: never }\n | { coerced: { [variable: string]: unknown }; errors?: never };\n\n/**\n * Prepares an object map of variableValues of the correct type based on the\n * provided variable definitions and arbitrary input. If the input cannot be\n * parsed to match the variable definitions, a GraphQLError will be thrown.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getVariableValues(\n resolvers: Resolvers,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n inputs: { [variable: string]: unknown },\n options?: { maxErrors?: number },\n): CoercedVariableValues {\n const errors = [];\n const maxErrors = options?.maxErrors;\n try {\n const coerced = coerceVariableValues(\n resolvers,\n varDefNodes,\n inputs,\n (error) => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw new GraphQLError(\n \"Too many errors processing variables, error limit reached. Execution aborted.\",\n );\n }\n errors.push(error);\n },\n );\n\n if (errors.length === 0) {\n return { coerced };\n }\n } catch (error) {\n errors.push(error);\n }\n\n return { errors: errors as GraphQLError[] };\n}\n\nfunction coerceVariableValues(\n resolvers: Resolvers,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n inputs: { [variable: string]: unknown },\n onError: (error: GraphQLError) => void,\n): { [variable: string]: unknown } {\n const coercedValues: { [variable: string]: unknown } = {};\n for (const varDefNode of varDefNodes) {\n const varName = varDefNode.variable.name.value;\n const varTypeAst = varDefNode.type;\n const varType: GraphQLType = graphqlTypeFromTypeAst(resolvers, varTypeAst);\n\n if (!isInputType(varType)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n const varTypeStr = inspect(varType);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`,\n varDefNode.type as GraphQLTypeNode,\n ),\n );\n continue;\n }\n\n if (!hasOwnProperty(inputs, varName)) {\n if (varDefNode.defaultValue) {\n coercedValues[varName] = valueFromAST(\n varDefNode.defaultValue as Maybe<GraphQLValueNode>,\n varType,\n );\n } else if (isNonNullType(varType)) {\n const varTypeStr = print(varDefNode.type as GraphQLTypeNode);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of required type \"${varTypeStr}\" was not provided.`,\n varDefNode as GraphQLVariableDefinitionNode,\n ),\n );\n }\n continue;\n }\n\n const value = inputs[varName];\n if (value === null && isNonNullType(varType)) {\n const varTypeStr = inspect(varType);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of non-null type \"${varTypeStr}\" must not be null.`,\n varDefNode as GraphQLVariableDefinitionNode,\n ),\n );\n continue;\n }\n\n coercedValues[varName] = coerceInputValue(\n value,\n varType,\n (path, invalidValue, error) => {\n let prefix =\n `Variable \"$${varName}\" got invalid value ` + inspect(invalidValue);\n if (path.length > 0) {\n prefix += ` at \"${varName}${printPathArray(path)}\"`;\n }\n onError(\n new GraphQLError(\n prefix + \"; \" + error.message,\n varDefNode as GraphQLVariableDefinitionNode,\n undefined,\n undefined,\n undefined,\n error.originalError,\n ),\n );\n },\n );\n }\n\n return coercedValues;\n}\n\n/**\n * Prepares an object map of argument values given a list of argument\n * definitions and list of argument AST nodes.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getArgumentValues(\n resolvers: Resolvers,\n node: FieldNode | DirectiveNode,\n variableValues?: Maybe<ObjMap<unknown>>,\n): { [argument: string]: unknown } {\n const coercedValues: { [argument: string]: unknown } = {};\n\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argumentNodes = node.arguments ?? [];\n\n for (const argumentNode of argumentNodes) {\n const name = argumentNode.name.value;\n const argTypeNode = argumentNode.__type;\n const argType = graphqlTypeFromTypeAst(resolvers, argTypeNode);\n\n if (!isInputType(argType)) {\n throw new GraphQLError(\n `Argument \"$${name}\" expected value of type \"${inspect(\n argType,\n )}\" which cannot be used as an input type.`,\n argumentNode as GraphQLArgumentNode,\n );\n }\n\n let valueNode = argumentNode.value;\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n if (\n variableValues == null ||\n !hasOwnProperty(variableValues, variableName)\n ) {\n if (argumentNode.__defaultValue) {\n valueNode = argumentNode.__defaultValue;\n } else if (isNonNullType(argType)) {\n throw new GraphQLError(\n `Argument \"${name}\" of required type \"${inspect(argType)}\" ` +\n `was provided the variable \"$${variableName}\" which was not provided a runtime value.`,\n valueNode as GraphQLValueNode,\n );\n }\n\n continue;\n }\n }\n\n const coercedValue = valueFromAST(\n valueNode as GraphQLValueNode,\n argType,\n variableValues,\n );\n if (coercedValue === undefined) {\n // Note: ValuesOfCorrectTypeRule validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n throw new GraphQLError(\n `Argument \"${name}\" has invalid value ${print(\n valueNode as GraphQLValueNode,\n )}.`,\n valueNode as GraphQLValueNode,\n );\n }\n coercedValues[name] = coercedValue;\n }\n\n return coercedValues;\n}\n\n/**\n * Prepares an object map of argument values given a directive definition\n * and a AST node which may contain directives. Optionally also accepts a map\n * of variable values.\n *\n * If the directive does not exist on the node, returns undefined.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getDirectiveValues(\n directiveDef: GraphQLDirective,\n node: { directives?: ReadonlyArray<DirectiveNode> },\n resolvers: Resolvers,\n variableValues?: Maybe<ObjMap<unknown>>,\n): undefined | { [argument: string]: unknown } {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const directiveNode = node.directives?.find(\n (directive) => directive.name.value === directiveDef.name,\n );\n\n if (directiveNode) {\n return getArgumentValues(resolvers, directiveNode, variableValues);\n }\n}\n\nfunction hasOwnProperty(obj: unknown, prop: string): boolean {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport const specifiedScalars: { [key: string]: GraphQLScalarType } = {\n ID: GraphQLID,\n String: GraphQLString,\n Int: GraphQLInt,\n Float: GraphQLFloat,\n Boolean: GraphQLBoolean,\n};\n\nfunction graphqlTypeFromTypeAst(\n resolvers: Resolvers,\n node: TypeNode,\n): GraphQLType {\n if (node.kind === Kind.NON_NULL_TYPE) {\n return new GraphQLNonNull(graphqlTypeFromTypeAst(resolvers, node.type));\n } else if (node.kind === Kind.LIST_TYPE) {\n return new GraphQLList(graphqlTypeFromTypeAst(resolvers, node.type));\n } else {\n const typeName = node.name.value;\n const type = specifiedScalars[typeName] || resolvers[typeName];\n return type as unknown as GraphQLType;\n }\n}\n"],
4
+ "sourcesContent": ["import {\n ArgumentNode as GraphQLArgumentNode,\n GraphQLBoolean,\n GraphQLError,\n GraphQLFloat,\n GraphQLID,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLScalarType,\n GraphQLString,\n GraphQLType,\n isInputType,\n isNonNullType,\n Kind,\n print,\n TypeNode as GraphQLTypeNode,\n ValueNode as GraphQLValueNode,\n VariableDefinitionNode as GraphQLVariableDefinitionNode,\n valueFromAST,\n coerceInputValue,\n} from \"graphql\";\nimport {\n DirectiveNode,\n FieldNode,\n TypeNode,\n VariableDefinitionNode,\n} from \"@graphitation/supermassive-ast\";\nimport { inspect } from \"./jsutils/inspect\";\nimport type { Maybe } from \"./jsutils/Maybe\";\nimport type { ObjMap } from \"./jsutils/ObjMap\";\nimport { printPathArray } from \"./jsutils/printPathArray\";\nimport { Resolvers } from \"./types\";\nimport { GraphQLDirective } from \"./directives\";\n\ntype CoercedVariableValues =\n | { errors: Array<GraphQLError>; coerced?: never }\n | { coerced: { [variable: string]: unknown }; errors?: never };\n\n/**\n * Prepares an object map of variableValues of the correct type based on the\n * provided variable definitions and arbitrary input. If the input cannot be\n * parsed to match the variable definitions, a GraphQLError will be thrown.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getVariableValues(\n resolvers: Resolvers,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n inputs: { [variable: string]: unknown },\n options?: { maxErrors?: number },\n): CoercedVariableValues {\n const errors = [];\n const maxErrors = options?.maxErrors;\n try {\n const coerced = coerceVariableValues(\n resolvers,\n varDefNodes,\n inputs,\n (error) => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw new GraphQLError(\n \"Too many errors processing variables, error limit reached. Execution aborted.\",\n );\n }\n errors.push(error);\n },\n );\n\n if (errors.length === 0) {\n return { coerced };\n }\n } catch (error) {\n errors.push(error);\n }\n\n return { errors: errors as GraphQLError[] };\n}\n\nfunction coerceVariableValues(\n resolvers: Resolvers,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n inputs: { [variable: string]: unknown },\n onError: (error: GraphQLError) => void,\n): { [variable: string]: unknown } {\n const coercedValues: { [variable: string]: unknown } = {};\n for (const varDefNode of varDefNodes) {\n const varName = varDefNode.variable.name.value;\n const varTypeAst = varDefNode.type;\n const varType: GraphQLType = graphqlTypeFromTypeAst(resolvers, varTypeAst);\n\n if (!isInputType(varType)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n const varTypeStr = inspect(varType);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`,\n varDefNode.type as GraphQLTypeNode,\n ),\n );\n continue;\n }\n\n if (!hasOwnProperty(inputs, varName)) {\n if (varDefNode.defaultValue) {\n coercedValues[varName] = valueFromAST(\n varDefNode.defaultValue as Maybe<GraphQLValueNode>,\n varType,\n );\n } else if (isNonNullType(varType)) {\n const varTypeStr = print(varDefNode.type as GraphQLTypeNode);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of required type \"${varTypeStr}\" was not provided.`,\n varDefNode as GraphQLVariableDefinitionNode,\n ),\n );\n }\n continue;\n }\n\n const value = inputs[varName];\n if (value === null && isNonNullType(varType)) {\n const varTypeStr = inspect(varType);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of non-null type \"${varTypeStr}\" must not be null.`,\n varDefNode as GraphQLVariableDefinitionNode,\n ),\n );\n continue;\n }\n\n coercedValues[varName] = coerceInputValue(\n value,\n varType,\n (path, invalidValue, error) => {\n let prefix =\n `Variable \"$${varName}\" got invalid value ` + inspect(invalidValue);\n if (path.length > 0) {\n prefix += ` at \"${varName}${printPathArray(path)}\"`;\n }\n onError(\n new GraphQLError(\n prefix + \"; \" + error.message,\n varDefNode as GraphQLVariableDefinitionNode,\n undefined,\n undefined,\n undefined,\n error.originalError,\n ),\n );\n },\n );\n }\n\n return coercedValues;\n}\n\n/**\n * Prepares an object map of argument values given a list of argument\n * definitions and list of argument AST nodes.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getArgumentValues(\n resolvers: Resolvers,\n node: FieldNode | DirectiveNode,\n variableValues?: Maybe<ObjMap<unknown>>,\n): { [argument: string]: unknown } {\n const coercedValues: { [argument: string]: unknown } = {};\n\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argumentNodes = node.arguments ?? [];\n\n for (const argumentNode of argumentNodes) {\n const name = argumentNode.name.value;\n const argTypeNode = argumentNode.__type;\n const argType = graphqlTypeFromTypeAst(resolvers, argTypeNode);\n\n if (!isInputType(argType)) {\n throw new GraphQLError(\n `Argument \"$${name}\" expected value of type \"${inspect(\n argType,\n )}\" which cannot be used as an input type.`,\n argumentNode as GraphQLArgumentNode,\n );\n }\n\n let valueNode = argumentNode.value;\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n if (\n variableValues == null ||\n !hasOwnProperty(variableValues, variableName)\n ) {\n if (argumentNode.__defaultValue) {\n valueNode = argumentNode.__defaultValue;\n } else if (isNonNullType(argType)) {\n throw new GraphQLError(\n `Argument \"${name}\" of required type \"${inspect(argType)}\" ` +\n `was provided the variable \"$${variableName}\" which was not provided a runtime value.`,\n valueNode as GraphQLValueNode,\n );\n }\n\n continue;\n }\n }\n\n const coercedValue = valueFromAST(\n valueNode as GraphQLValueNode,\n argType,\n variableValues,\n );\n if (coercedValue === undefined) {\n // Note: ValuesOfCorrectTypeRule validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n throw new GraphQLError(\n `Argument \"${name}\" has invalid value ${print(\n valueNode as GraphQLValueNode,\n )}.`,\n valueNode as GraphQLValueNode,\n );\n }\n coercedValues[name] = coercedValue;\n }\n\n return coercedValues;\n}\n\n/**\n * Prepares an object map of argument values given a directive definition\n * and a AST node which may contain directives. Optionally also accepts a map\n * of variable values.\n *\n * If the directive does not exist on the node, returns undefined.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getDirectiveValues(\n directiveDef: GraphQLDirective,\n node: { directives?: ReadonlyArray<DirectiveNode> },\n resolvers: Resolvers,\n variableValues?: Maybe<ObjMap<unknown>>,\n): undefined | { [argument: string]: unknown } {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const directiveNode = node.directives?.find(\n (directive) => directive.name.value === directiveDef.name,\n );\n\n if (directiveNode) {\n return getArgumentValues(resolvers, directiveNode, variableValues);\n }\n}\n\nfunction hasOwnProperty(obj: unknown, prop: string): boolean {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport const specifiedScalars: { [key: string]: GraphQLScalarType } = {\n ID: GraphQLID,\n String: GraphQLString,\n Int: GraphQLInt,\n Float: GraphQLFloat,\n Boolean: GraphQLBoolean,\n};\n\nfunction graphqlTypeFromTypeAst(\n resolvers: Resolvers,\n node: TypeNode,\n): GraphQLType {\n if (node.kind === Kind.NON_NULL_TYPE) {\n return new GraphQLNonNull(graphqlTypeFromTypeAst(resolvers, node.type));\n } else if (node.kind === Kind.LIST_TYPE) {\n return new GraphQLList(graphqlTypeFromTypeAst(resolvers, node.type));\n } else {\n const typeName = node.name.value;\n const type = specifiedScalars[typeName] || resolvers[typeName];\n return type as unknown as GraphQLType;\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAqBO;AAOP,qBAAwB;AAGxB,4BAA+B;AAmBxB,SAAS,kBACd,WACA,aACA,QACA,SACuB;AACvB,QAAM,SAAS,CAAC;AAChB,QAAM,YAAY,mCAAS;AAC3B,MAAI;AACF,UAAM,UAAU;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA,CAAC,UAAU;AACT,YAAI,aAAa,QAAQ,OAAO,UAAU,WAAW;AACnD,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AACA,eAAO,KAAK,KAAK;AAAA,MACnB;AAAA,IACF;AAEA,QAAI,OAAO,WAAW,GAAG;AACvB,aAAO,EAAE,QAAQ;AAAA,IACnB;AAAA,EACF,SAAS,OAAP;AACA,WAAO,KAAK,KAAK;AAAA,EACnB;AAEA,SAAO,EAAE,OAAiC;AAC5C;AAEA,SAAS,qBACP,WACA,aACA,QACA,SACiC;AACjC,QAAM,gBAAiD,CAAC;AACxD,aAAW,cAAc,aAAa;AACpC,UAAM,UAAU,WAAW,SAAS,KAAK;AACzC,UAAM,aAAa,WAAW;AAC9B,UAAM,UAAuB,uBAAuB,WAAW,UAAU;AAEzE,QAAI,KAAC,4BAAY,OAAO,GAAG;AAGzB,YAAM,iBAAa,wBAAQ,OAAO;AAClC;AAAA,QACE,IAAI;AAAA,UACF,cAAc,oCAAoC;AAAA,UAClD,WAAW;AAAA,QACb;AAAA,MACF;AACA;AAAA,IACF;AAEA,QAAI,CAAC,eAAe,QAAQ,OAAO,GAAG;AACpC,UAAI,WAAW,cAAc;AAC3B,sBAAc,OAAO,QAAI;AAAA,UACvB,WAAW;AAAA,UACX;AAAA,QACF;AAAA,MACF,eAAW,8BAAc,OAAO,GAAG;AACjC,cAAM,iBAAa,sB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C7D,WAAO;AAAA,EACT;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/values.ts"],
4
- "sourcesContent": ["import {\n ArgumentNode as GraphQLArgumentNode,\n GraphQLBoolean,\n GraphQLError,\n GraphQLFloat,\n GraphQLID,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLScalarType,\n GraphQLString,\n GraphQLType,\n isInputType,\n isNonNullType,\n Kind,\n print,\n TypeNode as GraphQLTypeNode,\n ValueNode as GraphQLValueNode,\n VariableDefinitionNode as GraphQLVariableDefinitionNode,\n valueFromAST,\n coerceInputValue,\n} from \"graphql\";\nimport {\n DirectiveNode,\n FieldNode,\n TypeNode,\n VariableDefinitionNode,\n} from \"./ast/TypedAST\";\nimport { inspect } from \"./jsutils/inspect\";\nimport type { Maybe } from \"./jsutils/Maybe\";\nimport type { ObjMap } from \"./jsutils/ObjMap\";\nimport { printPathArray } from \"./jsutils/printPathArray\";\nimport { Resolvers } from \"./types\";\nimport { GraphQLDirective } from \"./directives\";\n\ntype CoercedVariableValues =\n | { errors: Array<GraphQLError>; coerced?: never }\n | { coerced: { [variable: string]: unknown }; errors?: never };\n\n/**\n * Prepares an object map of variableValues of the correct type based on the\n * provided variable definitions and arbitrary input. If the input cannot be\n * parsed to match the variable definitions, a GraphQLError will be thrown.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getVariableValues(\n resolvers: Resolvers,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n inputs: { [variable: string]: unknown },\n options?: { maxErrors?: number },\n): CoercedVariableValues {\n const errors = [];\n const maxErrors = options?.maxErrors;\n try {\n const coerced = coerceVariableValues(\n resolvers,\n varDefNodes,\n inputs,\n (error) => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw new GraphQLError(\n \"Too many errors processing variables, error limit reached. Execution aborted.\",\n );\n }\n errors.push(error);\n },\n );\n\n if (errors.length === 0) {\n return { coerced };\n }\n } catch (error) {\n errors.push(error);\n }\n\n return { errors: errors as GraphQLError[] };\n}\n\nfunction coerceVariableValues(\n resolvers: Resolvers,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n inputs: { [variable: string]: unknown },\n onError: (error: GraphQLError) => void,\n): { [variable: string]: unknown } {\n const coercedValues: { [variable: string]: unknown } = {};\n for (const varDefNode of varDefNodes) {\n const varName = varDefNode.variable.name.value;\n const varTypeAst = varDefNode.type;\n const varType: GraphQLType = graphqlTypeFromTypeAst(resolvers, varTypeAst);\n\n if (!isInputType(varType)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n const varTypeStr = inspect(varType);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`,\n varDefNode.type as GraphQLTypeNode,\n ),\n );\n continue;\n }\n\n if (!hasOwnProperty(inputs, varName)) {\n if (varDefNode.defaultValue) {\n coercedValues[varName] = valueFromAST(\n varDefNode.defaultValue as Maybe<GraphQLValueNode>,\n varType,\n );\n } else if (isNonNullType(varType)) {\n const varTypeStr = print(varDefNode.type as GraphQLTypeNode);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of required type \"${varTypeStr}\" was not provided.`,\n varDefNode as GraphQLVariableDefinitionNode,\n ),\n );\n }\n continue;\n }\n\n const value = inputs[varName];\n if (value === null && isNonNullType(varType)) {\n const varTypeStr = inspect(varType);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of non-null type \"${varTypeStr}\" must not be null.`,\n varDefNode as GraphQLVariableDefinitionNode,\n ),\n );\n continue;\n }\n\n coercedValues[varName] = coerceInputValue(\n value,\n varType,\n (path, invalidValue, error) => {\n let prefix =\n `Variable \"$${varName}\" got invalid value ` + inspect(invalidValue);\n if (path.length > 0) {\n prefix += ` at \"${varName}${printPathArray(path)}\"`;\n }\n onError(\n new GraphQLError(\n prefix + \"; \" + error.message,\n varDefNode as GraphQLVariableDefinitionNode,\n undefined,\n undefined,\n undefined,\n error.originalError,\n ),\n );\n },\n );\n }\n\n return coercedValues;\n}\n\n/**\n * Prepares an object map of argument values given a list of argument\n * definitions and list of argument AST nodes.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getArgumentValues(\n resolvers: Resolvers,\n node: FieldNode | DirectiveNode,\n variableValues?: Maybe<ObjMap<unknown>>,\n): { [argument: string]: unknown } {\n const coercedValues: { [argument: string]: unknown } = {};\n\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argumentNodes = node.arguments ?? [];\n\n for (const argumentNode of argumentNodes) {\n const name = argumentNode.name.value;\n const argTypeNode = argumentNode.__type;\n const argType = graphqlTypeFromTypeAst(resolvers, argTypeNode);\n\n if (!isInputType(argType)) {\n throw new GraphQLError(\n `Argument \"$${name}\" expected value of type \"${inspect(\n argType,\n )}\" which cannot be used as an input type.`,\n argumentNode as GraphQLArgumentNode,\n );\n }\n\n let valueNode = argumentNode.value;\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n if (\n variableValues == null ||\n !hasOwnProperty(variableValues, variableName)\n ) {\n if (argumentNode.__defaultValue) {\n valueNode = argumentNode.__defaultValue;\n } else if (isNonNullType(argType)) {\n throw new GraphQLError(\n `Argument \"${name}\" of required type \"${inspect(argType)}\" ` +\n `was provided the variable \"$${variableName}\" which was not provided a runtime value.`,\n valueNode as GraphQLValueNode,\n );\n }\n\n continue;\n }\n }\n\n const coercedValue = valueFromAST(\n valueNode as GraphQLValueNode,\n argType,\n variableValues,\n );\n if (coercedValue === undefined) {\n // Note: ValuesOfCorrectTypeRule validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n throw new GraphQLError(\n `Argument \"${name}\" has invalid value ${print(\n valueNode as GraphQLValueNode,\n )}.`,\n valueNode as GraphQLValueNode,\n );\n }\n coercedValues[name] = coercedValue;\n }\n\n return coercedValues;\n}\n\n/**\n * Prepares an object map of argument values given a directive definition\n * and a AST node which may contain directives. Optionally also accepts a map\n * of variable values.\n *\n * If the directive does not exist on the node, returns undefined.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getDirectiveValues(\n directiveDef: GraphQLDirective,\n node: { directives?: ReadonlyArray<DirectiveNode> },\n resolvers: Resolvers,\n variableValues?: Maybe<ObjMap<unknown>>,\n): undefined | { [argument: string]: unknown } {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const directiveNode = node.directives?.find(\n (directive) => directive.name.value === directiveDef.name,\n );\n\n if (directiveNode) {\n return getArgumentValues(resolvers, directiveNode, variableValues);\n }\n}\n\nfunction hasOwnProperty(obj: unknown, prop: string): boolean {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport const specifiedScalars: { [key: string]: GraphQLScalarType } = {\n ID: GraphQLID,\n String: GraphQLString,\n Int: GraphQLInt,\n Float: GraphQLFloat,\n Boolean: GraphQLBoolean,\n};\n\nfunction graphqlTypeFromTypeAst(\n resolvers: Resolvers,\n node: TypeNode,\n): GraphQLType {\n if (node.kind === Kind.NON_NULL_TYPE) {\n return new GraphQLNonNull(graphqlTypeFromTypeAst(resolvers, node.type));\n } else if (node.kind === Kind.LIST_TYPE) {\n return new GraphQLList(graphqlTypeFromTypeAst(resolvers, node.type));\n } else {\n const typeName = node.name.value;\n const type = specifiedScalars[typeName] || resolvers[typeName];\n return type as unknown as GraphQLType;\n }\n}\n"],
4
+ "sourcesContent": ["import {\n ArgumentNode as GraphQLArgumentNode,\n GraphQLBoolean,\n GraphQLError,\n GraphQLFloat,\n GraphQLID,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLScalarType,\n GraphQLString,\n GraphQLType,\n isInputType,\n isNonNullType,\n Kind,\n print,\n TypeNode as GraphQLTypeNode,\n ValueNode as GraphQLValueNode,\n VariableDefinitionNode as GraphQLVariableDefinitionNode,\n valueFromAST,\n coerceInputValue,\n} from \"graphql\";\nimport {\n DirectiveNode,\n FieldNode,\n TypeNode,\n VariableDefinitionNode,\n} from \"@graphitation/supermassive-ast\";\nimport { inspect } from \"./jsutils/inspect\";\nimport type { Maybe } from \"./jsutils/Maybe\";\nimport type { ObjMap } from \"./jsutils/ObjMap\";\nimport { printPathArray } from \"./jsutils/printPathArray\";\nimport { Resolvers } from \"./types\";\nimport { GraphQLDirective } from \"./directives\";\n\ntype CoercedVariableValues =\n | { errors: Array<GraphQLError>; coerced?: never }\n | { coerced: { [variable: string]: unknown }; errors?: never };\n\n/**\n * Prepares an object map of variableValues of the correct type based on the\n * provided variable definitions and arbitrary input. If the input cannot be\n * parsed to match the variable definitions, a GraphQLError will be thrown.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getVariableValues(\n resolvers: Resolvers,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n inputs: { [variable: string]: unknown },\n options?: { maxErrors?: number },\n): CoercedVariableValues {\n const errors = [];\n const maxErrors = options?.maxErrors;\n try {\n const coerced = coerceVariableValues(\n resolvers,\n varDefNodes,\n inputs,\n (error) => {\n if (maxErrors != null && errors.length >= maxErrors) {\n throw new GraphQLError(\n \"Too many errors processing variables, error limit reached. Execution aborted.\",\n );\n }\n errors.push(error);\n },\n );\n\n if (errors.length === 0) {\n return { coerced };\n }\n } catch (error) {\n errors.push(error);\n }\n\n return { errors: errors as GraphQLError[] };\n}\n\nfunction coerceVariableValues(\n resolvers: Resolvers,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n inputs: { [variable: string]: unknown },\n onError: (error: GraphQLError) => void,\n): { [variable: string]: unknown } {\n const coercedValues: { [variable: string]: unknown } = {};\n for (const varDefNode of varDefNodes) {\n const varName = varDefNode.variable.name.value;\n const varTypeAst = varDefNode.type;\n const varType: GraphQLType = graphqlTypeFromTypeAst(resolvers, varTypeAst);\n\n if (!isInputType(varType)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n const varTypeStr = inspect(varType);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" expected value of type \"${varTypeStr}\" which cannot be used as an input type.`,\n varDefNode.type as GraphQLTypeNode,\n ),\n );\n continue;\n }\n\n if (!hasOwnProperty(inputs, varName)) {\n if (varDefNode.defaultValue) {\n coercedValues[varName] = valueFromAST(\n varDefNode.defaultValue as Maybe<GraphQLValueNode>,\n varType,\n );\n } else if (isNonNullType(varType)) {\n const varTypeStr = print(varDefNode.type as GraphQLTypeNode);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of required type \"${varTypeStr}\" was not provided.`,\n varDefNode as GraphQLVariableDefinitionNode,\n ),\n );\n }\n continue;\n }\n\n const value = inputs[varName];\n if (value === null && isNonNullType(varType)) {\n const varTypeStr = inspect(varType);\n onError(\n new GraphQLError(\n `Variable \"$${varName}\" of non-null type \"${varTypeStr}\" must not be null.`,\n varDefNode as GraphQLVariableDefinitionNode,\n ),\n );\n continue;\n }\n\n coercedValues[varName] = coerceInputValue(\n value,\n varType,\n (path, invalidValue, error) => {\n let prefix =\n `Variable \"$${varName}\" got invalid value ` + inspect(invalidValue);\n if (path.length > 0) {\n prefix += ` at \"${varName}${printPathArray(path)}\"`;\n }\n onError(\n new GraphQLError(\n prefix + \"; \" + error.message,\n varDefNode as GraphQLVariableDefinitionNode,\n undefined,\n undefined,\n undefined,\n error.originalError,\n ),\n );\n },\n );\n }\n\n return coercedValues;\n}\n\n/**\n * Prepares an object map of argument values given a list of argument\n * definitions and list of argument AST nodes.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n *\n * @internal\n */\nexport function getArgumentValues(\n resolvers: Resolvers,\n node: FieldNode | DirectiveNode,\n variableValues?: Maybe<ObjMap<unknown>>,\n): { [argument: string]: unknown } {\n const coercedValues: { [argument: string]: unknown } = {};\n\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const argumentNodes = node.arguments ?? [];\n\n for (const argumentNode of argumentNodes) {\n const name = argumentNode.name.value;\n const argTypeNode = argumentNode.__type;\n const argType = graphqlTypeFromTypeAst(resolvers, argTypeNode);\n\n if (!isInputType(argType)) {\n throw new GraphQLError(\n `Argument \"$${name}\" expected value of type \"${inspect(\n argType,\n )}\" which cannot be used as an input type.`,\n argumentNode as GraphQLArgumentNode,\n );\n }\n\n let valueNode = argumentNode.value;\n\n if (valueNode.kind === Kind.VARIABLE) {\n const variableName = valueNode.name.value;\n if (\n variableValues == null ||\n !hasOwnProperty(variableValues, variableName)\n ) {\n if (argumentNode.__defaultValue) {\n valueNode = argumentNode.__defaultValue;\n } else if (isNonNullType(argType)) {\n throw new GraphQLError(\n `Argument \"${name}\" of required type \"${inspect(argType)}\" ` +\n `was provided the variable \"$${variableName}\" which was not provided a runtime value.`,\n valueNode as GraphQLValueNode,\n );\n }\n\n continue;\n }\n }\n\n const coercedValue = valueFromAST(\n valueNode as GraphQLValueNode,\n argType,\n variableValues,\n );\n if (coercedValue === undefined) {\n // Note: ValuesOfCorrectTypeRule validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n throw new GraphQLError(\n `Argument \"${name}\" has invalid value ${print(\n valueNode as GraphQLValueNode,\n )}.`,\n valueNode as GraphQLValueNode,\n );\n }\n coercedValues[name] = coercedValue;\n }\n\n return coercedValues;\n}\n\n/**\n * Prepares an object map of argument values given a directive definition\n * and a AST node which may contain directives. Optionally also accepts a map\n * of variable values.\n *\n * If the directive does not exist on the node, returns undefined.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getDirectiveValues(\n directiveDef: GraphQLDirective,\n node: { directives?: ReadonlyArray<DirectiveNode> },\n resolvers: Resolvers,\n variableValues?: Maybe<ObjMap<unknown>>,\n): undefined | { [argument: string]: unknown } {\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const directiveNode = node.directives?.find(\n (directive) => directive.name.value === directiveDef.name,\n );\n\n if (directiveNode) {\n return getArgumentValues(resolvers, directiveNode, variableValues);\n }\n}\n\nfunction hasOwnProperty(obj: unknown, prop: string): boolean {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport const specifiedScalars: { [key: string]: GraphQLScalarType } = {\n ID: GraphQLID,\n String: GraphQLString,\n Int: GraphQLInt,\n Float: GraphQLFloat,\n Boolean: GraphQLBoolean,\n};\n\nfunction graphqlTypeFromTypeAst(\n resolvers: Resolvers,\n node: TypeNode,\n): GraphQLType {\n if (node.kind === Kind.NON_NULL_TYPE) {\n return new GraphQLNonNull(graphqlTypeFromTypeAst(resolvers, node.type));\n } else if (node.kind === Kind.LIST_TYPE) {\n return new GraphQLList(graphqlTypeFromTypeAst(resolvers, node.type));\n } else {\n const typeName = node.name.value;\n const type = specifiedScalars[typeName] || resolvers[typeName];\n return type as unknown as GraphQLType;\n }\n}\n"],
5
5
  "mappings": ";AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,OACK;AAOP,SAAS,eAAe;AAGxB,SAAS,sBAAsB;AAmBxB,SAAS,kBACd,WACA,aACA,QACA,SACuB;AACvB,QAAM,SAAS,CAAC;AAChB,QAAM,YAAY,mCAAS;AAC3B,MAAI;AACF,UAAM,UAAU;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA,CAAC,UAAU;AACT,YAAI,aAAa,QAAQ,OAAO,UAAU,WAAW;AACnD,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AACA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AS,mBACd,cACA,MACA,WACA,gBAC6C;AAlQ/C;AAoQE,QAAM,iBAAgB,UAAK,eAAL,mBAAiB;AAAA,IACrC,CAAC,cAAc,UAAU,KAAK,UAAU,aAAa;AAAA;AAGvD,MAAI,eAAe;AACjB,WAAO,kBAAkB,WAAW,eAAe,cAAc;AAAA,EACnE;AACF;AAEA,SAAS,eAAe,KAAc,MAAuB;AAC3D,SAAO,OAAO,UAAU,eAAe,KAAK,KAAK,IAAI;AACvD;AAEO,IAAM,mBAAyD;AAAA,EACpE,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AACX;AAEA,SAAS,uBACP,WACA,MACa;AACb,MAAI,KAAK,SAAS,KAAK,eAAe;AACpC,WAAO,IAAI,eAAe,uBAAuB,WAAW,KAAK,IAAI,CAAC;AAAA,EACxE,WAAW,KAAK,SAAS,KAAK,WAAW;AACvC,WAAO,IAAI,YAAY,uBAAuB,WAAW,KAAK,IAAI,CAAC;AAAA,EACrE,OAAO;AACL,UAAM,WAAW,KAAK,KAAK;AAC3B,UAAM,OAAO,iBAAiB,QAAQ,KAAK,UAAU,QAAQ;AAC7D,WAAO;AAAA,EACT;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@graphitation/supermassive",
3
3
  "license": "MIT",
4
- "version": "2.4.8",
4
+ "version": "2.6.0",
5
5
  "main": "./lib/index",
6
6
  "repository": {
7
7
  "type": "git",
@@ -31,16 +31,15 @@
31
31
  "iterall": "^1.3.0",
32
32
  "monorepo-scripts": "*",
33
33
  "node-json-db": "^1.3.0",
34
- "ts-node": "^10.0.0"
34
+ "ts-node": "^10.0.0",
35
+ "typescript": "^4.9.5"
35
36
  },
36
37
  "sideEffects": false,
37
38
  "access": "public",
38
39
  "publishConfig": {},
39
40
  "dependencies": {
40
- "@graphql-tools/schema": "^9.0.19",
41
- "commander": "^8.3.0",
42
- "graphql": "^15.6.1",
43
- "typescript": "^4.4.3 <4.5.0"
41
+ "@graphitation/supermassive-ast": "*",
42
+ "graphql": "^15.6.1"
44
43
  },
45
44
  "types": "./lib/index.d.ts",
46
45
  "module": "./lib/index.mjs",