From 63f8b64b17a98e82db5ec56c324f6ca9d2c168aa Mon Sep 17 00:00:00 2001 From: "igor.luckenkov" Date: Sat, 29 Oct 2022 19:08:43 +0100 Subject: [PATCH 01/13] bumped graphql dependency to 17, migrated to new GraphQLError/getRootType syntax since old versions were deprecated and removed from graphql@17 --- package.json | 4 ++-- src/__tests__/json.test.ts | 4 +--- src/__tests__/schema.test.ts | 3 +-- src/__tests__/subscription.test.ts | 6 +++--- src/__tests__/variables.test.ts | 2 +- src/ast.ts | 27 ++++++++++----------------- src/compat.ts | 27 --------------------------- src/execution.ts | 7 ++++--- src/get-root-type.ts | 15 +++++++++++++++ src/json.ts | 8 +++----- src/non-null.ts | 7 ++----- yarn.lock | 8 ++++---- 12 files changed, 46 insertions(+), 72 deletions(-) delete mode 100644 src/compat.ts create mode 100644 src/get-root-type.ts diff --git a/package.json b/package.json index bd2440d1..3bf0e8e8 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ } }, "peerDependencies": { - "graphql": ">=15" + "graphql": ">=17" }, "devDependencies": { "@graphql-tools/schema": "^8.3.1", @@ -72,7 +72,7 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.1.1", "eslint-plugin-standard": "^5.0.0", - "graphql": "^16.0.0", + "graphql": "^17.0.0-alpha.2", "jest": "^27.4.3", "lint-staged": "^8.1.5", "prettier": "^2.4.1", diff --git a/src/__tests__/json.test.ts b/src/__tests__/json.test.ts index 72c51a4a..6a159fd3 100644 --- a/src/__tests__/json.test.ts +++ b/src/__tests__/json.test.ts @@ -1,6 +1,5 @@ import fastJson from "fast-json-stringify"; import { - formatError, GraphQLBoolean, GraphQLError, GraphQLID, @@ -11,7 +10,6 @@ import { GraphQLString, parse, GraphQLInt, - GraphQLScalarType, versionInfo } from "graphql"; import { buildExecutionContext } from "graphql/execution/execute"; @@ -163,7 +161,7 @@ describe("json schema creator", () => { test("error response serialization", async () => { const stringify = fastJson(jsonSchema); const response = { - errors: [formatError(new GraphQLError("test"))] + errors: [new GraphQLError("test").toJSON()] }; expect(stringify(response)).toEqual(JSON.stringify(response)); }); diff --git a/src/__tests__/schema.test.ts b/src/__tests__/schema.test.ts index 8a4a1fb0..8a09d670 100644 --- a/src/__tests__/schema.test.ts +++ b/src/__tests__/schema.test.ts @@ -18,8 +18,7 @@ import { GraphQLString, IntrospectionQuery, parse, - printSchema, - versionInfo + printSchema } from "graphql"; import { compileQuery, isCompiledQuery } from "../index"; diff --git a/src/__tests__/subscription.test.ts b/src/__tests__/subscription.test.ts index 18c44642..765421f5 100644 --- a/src/__tests__/subscription.test.ts +++ b/src/__tests__/subscription.test.ts @@ -8,6 +8,7 @@ */ import { + ExecutionArgs, ExecutionResult, GraphQLBoolean, GraphQLInt, @@ -15,8 +16,7 @@ import { GraphQLObjectType, GraphQLSchema, GraphQLString, - parse, - SubscriptionArgs + parse } from "graphql"; import { compileQuery, isAsyncIterable, isCompiledQuery } from "../execution"; @@ -68,7 +68,7 @@ async function subscribe({ rootValue, contextValue, variableValues -}: SubscriptionArgs): Promise< +}: ExecutionArgs): Promise< AsyncIterableIterator | ExecutionResult > { const prepared = compileQuery(schema, document, operationName || ""); diff --git a/src/__tests__/variables.test.ts b/src/__tests__/variables.test.ts index eeced9b4..4df23de0 100644 --- a/src/__tests__/variables.test.ts +++ b/src/__tests__/variables.test.ts @@ -283,7 +283,7 @@ describe("Execute: Handles inputs", () => { errors: [ { message: - 'Argument "input" of type "TestInputObject" has invalid value {b: ["A", null, "C"], c: false}.', + 'Argument "input" of type "TestInputObject" has invalid value { b: ["A", null, "C"], c: false }.', locations: [{ line: 3, column: 41 }] } ] diff --git a/src/ast.ts b/src/ast.ts index 2d39c07e..de833327 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -26,10 +26,8 @@ import { typeFromAST, valueFromASTUntyped, ValueNode, - VariableNode, - versionInfo + VariableNode } from "graphql"; -import { getFieldDef } from "graphql/execution/execute"; import { Kind, SelectionNode, TypeNode } from "graphql/language"; import { isAbstractType } from "graphql/type"; import { CompilationContext, GLOBAL_VARIABLES_NAME } from "./execution"; @@ -414,7 +412,7 @@ function compileSkipIncludeDirective( if (ifNode == null) { throw new GraphQLError( `Directive '${directive.name.value}' is missing required arguments: 'if'`, - [directive] + { nodes: [directive] } ); } @@ -431,7 +429,7 @@ function compileSkipIncludeDirective( }' has an invalid value (${valueFromASTUntyped( ifNode.value )}). Expected type 'Boolean!'`, - [ifNode] + { nodes: [ifNode] } ); } } @@ -454,9 +452,9 @@ function validateSkipIncludeVariableType( (it) => it.variable.name.value === variable.name.value ); if (variableDefinition == null) { - throw new GraphQLError(`Variable '${variable.name.value}' is not defined`, [ - variable - ]); + throw new GraphQLError(`Variable '${variable.name.value}' is not defined`, { + nodes: [variable] + }); } if ( @@ -470,7 +468,7 @@ function validateSkipIncludeVariableType( `Variable '${variable.name.value}' of type '${typeNodeToString( variableDefinition.type )}' used in position expecting type 'Boolean!'`, - [variableDefinition] + { nodes: [variableDefinition] } ); } } @@ -539,12 +537,7 @@ export function resolveFieldDef( ): Maybe> { const fieldNode = fieldNodes[0]; - if (versionInfo.major < 16) { - const fieldName = fieldNode.name.value; - return getFieldDef(compilationContext.schema, parentType, fieldName as any); - } - - return getFieldDef(compilationContext.schema, parentType, fieldNode as any); + return compilationContext.schema.getField(parentType, fieldNode.name.value); } /** @@ -686,7 +679,7 @@ export function getArgumentDefs( `Argument "${name}" of type "${argType}" has invalid value ${print( argumentNode.value )}.`, - argumentNode.value + { nodes: argumentNode.value } ); } @@ -709,7 +702,7 @@ export function getArgumentDefs( `"${argType}" must not be null.` : `Argument "${name}" of required type ` + `"${argType}" was not provided.`, - node + { nodes: node } ); } } diff --git a/src/compat.ts b/src/compat.ts deleted file mode 100644 index 4508ed9b..00000000 --- a/src/compat.ts +++ /dev/null @@ -1,27 +0,0 @@ -import * as GraphQL from "graphql"; - -/** - * A helper to support backward compatibility for different versions of graphql-js. - * - * v15 does not have schema.getRootType - * v16 has both - * v17 will not have getOperationRootType - * - * To support all these 3 versions of graphql-js, at least for migration, this helper - * would be useful. - * - * This can be removed once we drop support for v15. - * - * GraphQL v17 would remove getOperationRootType. - */ -export function getOperationRootType( - schema: GraphQL.GraphQLSchema, - operation: GraphQL.OperationDefinitionNode -) { - if (GraphQL.getOperationRootType) { - return GraphQL.getOperationRootType(schema, operation); - } else { - // the use of any is to support graphql v15 types which will not use this codepath - return (schema as any).getRootType(operation.operation)!; - } -} diff --git a/src/execution.ts b/src/execution.ts index dac6d382..ee87590b 100644 --- a/src/execution.ts +++ b/src/execution.ts @@ -47,7 +47,6 @@ import { ObjectPath, resolveFieldDef } from "./ast"; -import { getOperationRootType } from "./compat"; import { GraphQLError as GraphqlJitError } from "./error"; import createInspect from "./inspect"; import { queryToJSONSchema } from "./json"; @@ -62,6 +61,7 @@ import { compileVariableParsing, failToParseVariables } from "./variables"; +import { getRootType } from "./get-root-type"; const inspect = createInspect(); @@ -248,7 +248,8 @@ export function compileQuery< context.operation.variableDefinitions || [] ); - const type = getOperationRootType(context.schema, context.operation); + const type = getRootType(context); + const fieldMap = collectFields( context, type, @@ -1706,7 +1707,7 @@ function compileSubscriptionOperation( if (!field) { throw new GraphQLError( `The subscription field "${fieldName}" is not defined.`, - fieldNodes + { nodes: fieldNodes } ); } diff --git a/src/get-root-type.ts b/src/get-root-type.ts new file mode 100644 index 00000000..e68f7360 --- /dev/null +++ b/src/get-root-type.ts @@ -0,0 +1,15 @@ +import { CompilationContext } from "./execution"; + +export const getRootType = (compilationContext: CompilationContext) => { + const type = compilationContext.schema.getRootType( + compilationContext.operation.operation + ); + + if (!type) { + throw new Error( + `No root type for operation ${compilationContext.operation.operation}` + ); + } + + return type; +}; diff --git a/src/json.ts b/src/json.ts index ed56f677..d804adc4 100644 --- a/src/json.ts +++ b/src/json.ts @@ -15,8 +15,8 @@ import { } from "graphql"; import { JSONSchema6, JSONSchema6TypeName } from "json-schema"; import { collectFields, collectSubfields, resolveFieldDef } from "./ast"; -import { getOperationRootType } from "./compat"; import { CompilationContext } from "./execution"; +import { getRootType } from "./get-root-type"; const PRIMITIVES: { [key: string]: JSONSchema6TypeName } = { Int: "integer", @@ -35,10 +35,8 @@ const PRIMITIVES: { [key: string]: JSONSchema6TypeName } = { export function queryToJSONSchema( compilationContext: CompilationContext ): JSONSchema6 { - const type = getOperationRootType( - compilationContext.schema, - compilationContext.operation - ); + const type = getRootType(compilationContext); + const fields = collectFields( compilationContext, type, diff --git a/src/non-null.ts b/src/non-null.ts index e89418be..391c1caf 100644 --- a/src/non-null.ts +++ b/src/non-null.ts @@ -10,8 +10,8 @@ import { import { isAbstractType } from "graphql/type"; import merge from "lodash.merge"; import { collectFields, collectSubfields, resolveFieldDef } from "./ast"; -import { getOperationRootType } from "./compat"; import { CompilationContext } from "./execution"; +import { getRootType } from "./get-root-type"; interface QueryMetadata { isNullable: boolean; @@ -135,10 +135,7 @@ function findNullableAncestor( function parseQueryNullables( compilationContext: CompilationContext ): QueryMetadata { - const type = getOperationRootType( - compilationContext.schema, - compilationContext.operation - ); + const type = getRootType(compilationContext); const fields = collectFields( compilationContext, type, diff --git a/yarn.lock b/yarn.lock index 47b66016..4120737f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2653,10 +2653,10 @@ graceful-fs@^4.2.4: resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a" integrity sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg== -graphql@^16.0.0: - version "16.2.0" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.2.0.tgz#de3150e80f1fc009590b92a9d16ab1b46e12b656" - integrity sha512-MuQd7XXrdOcmfwuLwC2jNvx0n3rxIuNYOxUtiee5XOmfrWo613ar2U8pE7aHAKh8VwfpifubpD9IP+EdEAEOsA== +graphql@^17.0.0-alpha.2: + version "17.0.0-alpha.2" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-17.0.0-alpha.2.tgz#c8be4605f7beb47abb70f67fead4854aab22152d" + integrity sha512-aRAd/BQ5hSO0+l7x+sHBfJVUp2JUOjPTE/iwJ3BhtYNH/MC7n4gjlZbKvnBVFZZAczyMS3vezS4teEZivoqIzw== has-ansi@^2.0.0: version "2.0.0" From 2a0407c1d72864936fbbc92372a73de3f847d064 Mon Sep 17 00:00:00 2001 From: "igor.luckenkov" Date: Mon, 14 Nov 2022 20:30:18 +0000 Subject: [PATCH 02/13] bump dependencies --- package.json | 2 +- yarn.lock | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 3bf0e8e8..70e74cad 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "graphql": ">=17" }, "devDependencies": { - "@graphql-tools/schema": "^8.3.1", + "@graphql-tools/schema": "^9.0.8", "@stryker-mutator/core": "^2.0.0", "@stryker-mutator/jest-runner": "^2.0.0", "@stryker-mutator/typescript": "^2.0.0", diff --git a/yarn.lock b/yarn.lock index 4120737f..886589da 100644 --- a/yarn.lock +++ b/yarn.lock @@ -446,30 +446,30 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" -"@graphql-tools/merge@^8.2.1": - version "8.2.1" - resolved "https://registry.yarnpkg.com/@graphql-tools/merge/-/merge-8.2.1.tgz#bf83aa06a0cfc6a839e52a58057a84498d0d51ff" - integrity sha512-Q240kcUszhXiAYudjuJgNuLgy9CryDP3wp83NOZQezfA6h3ByYKU7xI6DiKrdjyVaGpYN3ppUmdj0uf5GaXzMA== - dependencies: - "@graphql-tools/utils" "^8.5.1" - tslib "~2.3.0" - -"@graphql-tools/schema@^8.3.1": - version "8.3.1" - resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-8.3.1.tgz#1ee9da494d2da457643b3c93502b94c3c4b68c74" - integrity sha512-3R0AJFe715p4GwF067G5i0KCr/XIdvSfDLvTLEiTDQ8V/hwbOHEKHKWlEBHGRQwkG5lwFQlW1aOn7VnlPERnWQ== - dependencies: - "@graphql-tools/merge" "^8.2.1" - "@graphql-tools/utils" "^8.5.1" - tslib "~2.3.0" +"@graphql-tools/merge@8.3.10": + version "8.3.10" + resolved "https://registry.yarnpkg.com/@graphql-tools/merge/-/merge-8.3.10.tgz#81f374bc1e8c81d45cb1003d8ed05f181b7e6bd5" + integrity sha512-/hSg69JwqEA+t01wQmMGKPuaJ9VJBSz6uAXhbNNrTBJu8bmXljw305NVXM49pCwDKFVUGtbTqYrBeLcfT3RoYw== + dependencies: + "@graphql-tools/utils" "9.0.1" + tslib "^2.4.0" + +"@graphql-tools/schema@^9.0.8": + version "9.0.8" + resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-9.0.8.tgz#df3119c8543e6dacf425998f83aa714e2ee86eb0" + integrity sha512-PnES7sNkhQ/FdPQhP7cup0OIzwzQh+nfjklilU7YJzE209ACIyEQtxoNCfvPW5eV6hc9bWsBQeI3Jm4mMtwxNA== + dependencies: + "@graphql-tools/merge" "8.3.10" + "@graphql-tools/utils" "9.0.1" + tslib "^2.4.0" value-or-promise "1.0.11" -"@graphql-tools/utils@^8.5.1": - version "8.6.1" - resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-8.6.1.tgz#52c7eb108f2ca2fd01bdba8eef85077ead1bf882" - integrity sha512-uxcfHCocp4ENoIiovPxUWZEHOnbXqj3ekWc0rm7fUhW93a1xheARNHcNKhwMTR+UKXVJbTFQdGI1Rl5XdyvDBg== +"@graphql-tools/utils@9.0.1": + version "9.0.1" + resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-9.0.1.tgz#04933b34c3435ef9add4f8bdfdf452040376f9d0" + integrity sha512-z6FimVa5E44bHKmqK0/uMp9hHvHo2Tkt9A5rlLb40ReD/8IFKehSXLzM4b2N1vcP7mSsbXIdDK9Aoc8jT/he1Q== dependencies: - tslib "~2.3.0" + tslib "^2.4.0" "@graphql-typed-document-node/core@^3.1.1": version "3.1.1" @@ -5374,10 +5374,10 @@ tslib@^1.8.1, tslib@^1.9.0, tslib@~1.9.3: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== -tslib@~2.3.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" - integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== +tslib@^2.4.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.1.tgz#0d0bfbaac2880b91e22df0768e55be9753a5b17e" + integrity sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA== tsutils@^3.21.0: version "3.21.0" From 83ae6f55b32cda318df5dad4988b5b10e83b444d Mon Sep 17 00:00:00 2001 From: Oskari Porkka Date: Thu, 26 Jan 2023 12:14:37 +0100 Subject: [PATCH 03/13] Test with GraphQL 17 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c804fc4b..ef924f47 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: matrix: node-version: [14, 16, 18] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - graphql-version: [15, 16] + graphql-version: [15, 16, 17] steps: - uses: actions/checkout@v2 From 07dfe5efad359135d00f510187c99faae9fe7805 Mon Sep 17 00:00:00 2001 From: Oskari Porkka Date: Thu, 26 Jan 2023 12:17:06 +0100 Subject: [PATCH 04/13] Specify alpha separately --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ef924f47..95bdaad5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: matrix: node-version: [14, 16, 18] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - graphql-version: [15, 16, 17] + graphql-version: [15, 16, 17.0.0-alpha.2] steps: - uses: actions/checkout@v2 From 9cff6e1ebee6831cb8e82af9889e843d8fdbfec6 Mon Sep 17 00:00:00 2001 From: "igor.luckenkov" Date: Fri, 27 Jan 2023 19:12:21 +0000 Subject: [PATCH 05/13] graphql-17: support graphql version 16 --- src/__tests__/variables.test.ts | 7 +++++-- src/ast.ts | 26 ++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/__tests__/variables.test.ts b/src/__tests__/variables.test.ts index 4df23de0..ce2c34d1 100644 --- a/src/__tests__/variables.test.ts +++ b/src/__tests__/variables.test.ts @@ -16,7 +16,8 @@ import { GraphQLScalarType, GraphQLSchema, GraphQLString, - parse + parse, + versionInfo } from "graphql"; import { GraphQLArgumentConfig } from "graphql/type/definition"; import { compileQuery, isCompiledQuery } from "../index"; @@ -283,7 +284,9 @@ describe("Execute: Handles inputs", () => { errors: [ { message: - 'Argument "input" of type "TestInputObject" has invalid value { b: ["A", null, "C"], c: false }.', + versionInfo.major < 17 + ? 'Argument "input" of type "TestInputObject" has invalid value {b: ["A", null, "C"], c: false}.' + : 'Argument "input" of type "TestInputObject" has invalid value { b: ["A", null, "C"], c: false }.', locations: [{ line: 3, column: 41 }] } ] diff --git a/src/ast.ts b/src/ast.ts index de833327..1bb4a1e8 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -26,13 +26,15 @@ import { typeFromAST, valueFromASTUntyped, ValueNode, - VariableNode + VariableNode, + versionInfo } from "graphql"; import { Kind, SelectionNode, TypeNode } from "graphql/language"; import { isAbstractType } from "graphql/type"; import { CompilationContext, GLOBAL_VARIABLES_NAME } from "./execution"; import createInspect from "./inspect"; import { Maybe } from "./types"; +import * as execute from "graphql/execution/execute"; export interface JitFieldNode extends FieldNode { __internalShouldInclude?: string; @@ -537,7 +539,27 @@ export function resolveFieldDef( ): Maybe> { const fieldNode = fieldNodes[0]; - return compilationContext.schema.getField(parentType, fieldNode.name.value); + if (versionInfo.major < 16) { + const fieldName = fieldNode.name.value; + return execute.getFieldDef( + compilationContext.schema, + parentType, + fieldName as any + ); + } + + if (versionInfo.major < 17) { + return execute.getFieldDef( + compilationContext.schema, + parentType, + fieldNode as any + ); + } + + return (compilationContext.schema as any).getField( + parentType, + fieldNode.name.value + ); } /** From 887937c894229fe0581200ebcb387f5e4dabaef9 Mon Sep 17 00:00:00 2001 From: "igor.luckenkov" Date: Fri, 27 Jan 2023 19:33:44 +0000 Subject: [PATCH 06/13] graphql-17: support graphql version 15 --- src/__tests__/json.test.ts | 3 ++- src/ast.ts | 18 ++++++++++-------- src/execution.ts | 3 ++- src/format-error.ts | 11 +++++++++++ src/get-graphql-error-options.ts | 13 +++++++++++++ src/get-root-type.ts | 16 ++++++++++++++-- 6 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 src/format-error.ts create mode 100644 src/get-graphql-error-options.ts diff --git a/src/__tests__/json.test.ts b/src/__tests__/json.test.ts index 6a159fd3..ea1f2b79 100644 --- a/src/__tests__/json.test.ts +++ b/src/__tests__/json.test.ts @@ -15,6 +15,7 @@ import { import { buildExecutionContext } from "graphql/execution/execute"; import { compileQuery } from "../index"; import { queryToJSONSchema } from "../json"; +import { formatError } from "../format-error"; import { makeExecutableSchema } from "@graphql-tools/schema"; describe("json schema creator", () => { @@ -161,7 +162,7 @@ describe("json schema creator", () => { test("error response serialization", async () => { const stringify = fastJson(jsonSchema); const response = { - errors: [new GraphQLError("test").toJSON()] + errors: [formatError(new GraphQLError("test"))] }; expect(stringify(response)).toEqual(JSON.stringify(response)); }); diff --git a/src/ast.ts b/src/ast.ts index 1bb4a1e8..bda221e0 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -35,6 +35,7 @@ import { CompilationContext, GLOBAL_VARIABLES_NAME } from "./execution"; import createInspect from "./inspect"; import { Maybe } from "./types"; import * as execute from "graphql/execution/execute"; +import { getGraphQLErrorOptions } from "./get-graphql-error-options"; export interface JitFieldNode extends FieldNode { __internalShouldInclude?: string; @@ -414,7 +415,7 @@ function compileSkipIncludeDirective( if (ifNode == null) { throw new GraphQLError( `Directive '${directive.name.value}' is missing required arguments: 'if'`, - { nodes: [directive] } + getGraphQLErrorOptions([directive]) ); } @@ -431,7 +432,7 @@ function compileSkipIncludeDirective( }' has an invalid value (${valueFromASTUntyped( ifNode.value )}). Expected type 'Boolean!'`, - { nodes: [ifNode] } + getGraphQLErrorOptions([ifNode]) ); } } @@ -454,9 +455,10 @@ function validateSkipIncludeVariableType( (it) => it.variable.name.value === variable.name.value ); if (variableDefinition == null) { - throw new GraphQLError(`Variable '${variable.name.value}' is not defined`, { - nodes: [variable] - }); + throw new GraphQLError( + `Variable '${variable.name.value}' is not defined`, + getGraphQLErrorOptions([variable]) + ); } if ( @@ -470,7 +472,7 @@ function validateSkipIncludeVariableType( `Variable '${variable.name.value}' of type '${typeNodeToString( variableDefinition.type )}' used in position expecting type 'Boolean!'`, - { nodes: [variableDefinition] } + getGraphQLErrorOptions([variableDefinition]) ); } } @@ -701,7 +703,7 @@ export function getArgumentDefs( `Argument "${name}" of type "${argType}" has invalid value ${print( argumentNode.value )}.`, - { nodes: argumentNode.value } + getGraphQLErrorOptions(argumentNode.value) ); } @@ -724,7 +726,7 @@ export function getArgumentDefs( `"${argType}" must not be null.` : `Argument "${name}" of required type ` + `"${argType}" was not provided.`, - { nodes: node } + getGraphQLErrorOptions(node) ); } } diff --git a/src/execution.ts b/src/execution.ts index ee87590b..43773ab5 100644 --- a/src/execution.ts +++ b/src/execution.ts @@ -62,6 +62,7 @@ import { failToParseVariables } from "./variables"; import { getRootType } from "./get-root-type"; +import { getGraphQLErrorOptions } from "./get-graphql-error-options"; const inspect = createInspect(); @@ -1707,7 +1708,7 @@ function compileSubscriptionOperation( if (!field) { throw new GraphQLError( `The subscription field "${fieldName}" is not defined.`, - { nodes: fieldNodes } + getGraphQLErrorOptions(fieldNodes) ); } diff --git a/src/format-error.ts b/src/format-error.ts new file mode 100644 index 00000000..b81eaeed --- /dev/null +++ b/src/format-error.ts @@ -0,0 +1,11 @@ +import { GraphQLError, versionInfo } from "graphql"; +import * as utilities from "graphql/error"; +import { GraphQLFormattedError } from "graphql/error/formatError"; + +export const formatError = (error: GraphQLError): GraphQLFormattedError => { + if (versionInfo.major < 16) { + return (utilities as any).formatError(error); + } + + return (error as any).toJSON(); +}; diff --git a/src/get-graphql-error-options.ts b/src/get-graphql-error-options.ts new file mode 100644 index 00000000..d5e91158 --- /dev/null +++ b/src/get-graphql-error-options.ts @@ -0,0 +1,13 @@ +import { Maybe } from "graphql/jsutils/Maybe"; +import { ASTNode } from "graphql/language/ast"; +import { GraphQLError, versionInfo } from "graphql"; + +export const getGraphQLErrorOptions = ( + nodes: Maybe | ASTNode> +): ConstructorParameters[1] => { + if (versionInfo.major < 16) { + return nodes as any; + } + + return { nodes } as any; +}; diff --git a/src/get-root-type.ts b/src/get-root-type.ts index e68f7360..06af821e 100644 --- a/src/get-root-type.ts +++ b/src/get-root-type.ts @@ -1,7 +1,19 @@ import { CompilationContext } from "./execution"; +import { versionInfo } from "graphql"; +import * as utilities from "graphql/utilities"; +import { GraphQLObjectType } from "graphql/type/definition"; -export const getRootType = (compilationContext: CompilationContext) => { - const type = compilationContext.schema.getRootType( +export const getRootType = ( + compilationContext: CompilationContext +): GraphQLObjectType => { + if (versionInfo.major < 16) { + return (utilities as any).getOperationRootType( + compilationContext.schema, + compilationContext.operation + ); + } + + const type = (compilationContext.schema as any).getRootType( compilationContext.operation.operation ); From f27a194ea06d01692b706fa833ecb8475a62d6ec Mon Sep 17 00:00:00 2001 From: "igor.luckenkov" Date: Fri, 27 Jan 2023 19:34:21 +0000 Subject: [PATCH 07/13] graphql-17: updated yarn.lock --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 886589da..a899c9cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2654,9 +2654,9 @@ graceful-fs@^4.2.4: integrity sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg== graphql@^17.0.0-alpha.2: - version "17.0.0-alpha.2" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-17.0.0-alpha.2.tgz#c8be4605f7beb47abb70f67fead4854aab22152d" - integrity sha512-aRAd/BQ5hSO0+l7x+sHBfJVUp2JUOjPTE/iwJ3BhtYNH/MC7n4gjlZbKvnBVFZZAczyMS3vezS4teEZivoqIzw== + version "17.0.0-alpha.2.canary.pr.3791.264f22163eb937ff87a420be9f7d45965f2cbf07" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-17.0.0-alpha.2.canary.pr.3791.264f22163eb937ff87a420be9f7d45965f2cbf07.tgz#3835b1183f4a7a735d629df575a29cba3829f1ea" + integrity sha512-foJTYdXFHaZNx0M5eks57HBGSNwtfxQWcR7REVG3IB9Q0Ah3pumvN4Jk8GciWARv4/ySP/hKpGMqMFy1TKlqqg== has-ansi@^2.0.0: version "2.0.0" From aae9d94bcbba08824d4b348c6a8bd87bd727f151 Mon Sep 17 00:00:00 2001 From: "igor.luckenkov" Date: Fri, 27 Jan 2023 19:51:24 +0000 Subject: [PATCH 08/13] graphql-17: returned back to compat.ts --- src/compat.ts | 36 ++++++++++++++++++++++++++++++++++++ src/execution.ts | 5 ++--- src/get-root-type.ts | 27 --------------------------- src/json.ts | 8 +++++--- src/non-null.ts | 7 +++++-- 5 files changed, 48 insertions(+), 35 deletions(-) create mode 100644 src/compat.ts delete mode 100644 src/get-root-type.ts diff --git a/src/compat.ts b/src/compat.ts new file mode 100644 index 00000000..40b25726 --- /dev/null +++ b/src/compat.ts @@ -0,0 +1,36 @@ +import { GraphQLSchema, versionInfo } from "graphql"; +import * as utilities from "graphql/utilities"; +import { GraphQLObjectType } from "graphql/type/definition"; +import { OperationDefinitionNode } from "graphql/language/ast"; + +/** + * A helper to support backward compatibility for different versions of graphql-js. + * + * v15 does not have schema.getRootType + * v16 has both + * v17 will not have getOperationRootType + * + * To support all these 3 versions of graphql-js, at least for migration, this helper + * would be useful. + * + * This can be removed once we drop support for v15. + * + * GraphQL v17 would remove getOperationRootType. + */ + +export const getOperationRootType = ( + schema: GraphQLSchema, + operation: OperationDefinitionNode +): GraphQLObjectType => { + if (versionInfo.major < 16) { + return (utilities as any).getOperationRootType(schema, operation); + } + + const type = (schema as any).getRootType(operation.operation); + + if (!type) { + throw new Error(`No root type for operation ${operation.operation}`); + } + + return type; +}; diff --git a/src/execution.ts b/src/execution.ts index 43773ab5..59cc36aa 100644 --- a/src/execution.ts +++ b/src/execution.ts @@ -61,8 +61,8 @@ import { compileVariableParsing, failToParseVariables } from "./variables"; -import { getRootType } from "./get-root-type"; import { getGraphQLErrorOptions } from "./get-graphql-error-options"; +import { getOperationRootType } from "./compat"; const inspect = createInspect(); @@ -249,8 +249,7 @@ export function compileQuery< context.operation.variableDefinitions || [] ); - const type = getRootType(context); - + const type = getOperationRootType(context.schema, context.operation); const fieldMap = collectFields( context, type, diff --git a/src/get-root-type.ts b/src/get-root-type.ts deleted file mode 100644 index 06af821e..00000000 --- a/src/get-root-type.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { CompilationContext } from "./execution"; -import { versionInfo } from "graphql"; -import * as utilities from "graphql/utilities"; -import { GraphQLObjectType } from "graphql/type/definition"; - -export const getRootType = ( - compilationContext: CompilationContext -): GraphQLObjectType => { - if (versionInfo.major < 16) { - return (utilities as any).getOperationRootType( - compilationContext.schema, - compilationContext.operation - ); - } - - const type = (compilationContext.schema as any).getRootType( - compilationContext.operation.operation - ); - - if (!type) { - throw new Error( - `No root type for operation ${compilationContext.operation.operation}` - ); - } - - return type; -}; diff --git a/src/json.ts b/src/json.ts index d804adc4..ed56f677 100644 --- a/src/json.ts +++ b/src/json.ts @@ -15,8 +15,8 @@ import { } from "graphql"; import { JSONSchema6, JSONSchema6TypeName } from "json-schema"; import { collectFields, collectSubfields, resolveFieldDef } from "./ast"; +import { getOperationRootType } from "./compat"; import { CompilationContext } from "./execution"; -import { getRootType } from "./get-root-type"; const PRIMITIVES: { [key: string]: JSONSchema6TypeName } = { Int: "integer", @@ -35,8 +35,10 @@ const PRIMITIVES: { [key: string]: JSONSchema6TypeName } = { export function queryToJSONSchema( compilationContext: CompilationContext ): JSONSchema6 { - const type = getRootType(compilationContext); - + const type = getOperationRootType( + compilationContext.schema, + compilationContext.operation + ); const fields = collectFields( compilationContext, type, diff --git a/src/non-null.ts b/src/non-null.ts index 391c1caf..e89418be 100644 --- a/src/non-null.ts +++ b/src/non-null.ts @@ -10,8 +10,8 @@ import { import { isAbstractType } from "graphql/type"; import merge from "lodash.merge"; import { collectFields, collectSubfields, resolveFieldDef } from "./ast"; +import { getOperationRootType } from "./compat"; import { CompilationContext } from "./execution"; -import { getRootType } from "./get-root-type"; interface QueryMetadata { isNullable: boolean; @@ -135,7 +135,10 @@ function findNullableAncestor( function parseQueryNullables( compilationContext: CompilationContext ): QueryMetadata { - const type = getRootType(compilationContext); + const type = getOperationRootType( + compilationContext.schema, + compilationContext.operation + ); const fields = collectFields( compilationContext, type, From c68180a3312eff63b6d98e451c695a343ff4d27e Mon Sep 17 00:00:00 2001 From: "igor.luckenkov" Date: Fri, 27 Jan 2023 19:57:06 +0000 Subject: [PATCH 09/13] graphql-17: fix some TS errors --- src/ast.ts | 4 ++-- src/format-error.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ast.ts b/src/ast.ts index bda221e0..ca27e8d7 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -543,7 +543,7 @@ export function resolveFieldDef( if (versionInfo.major < 16) { const fieldName = fieldNode.name.value; - return execute.getFieldDef( + return (execute as any).getFieldDef( compilationContext.schema, parentType, fieldName as any @@ -551,7 +551,7 @@ export function resolveFieldDef( } if (versionInfo.major < 17) { - return execute.getFieldDef( + return (execute as any).getFieldDef( compilationContext.schema, parentType, fieldNode as any diff --git a/src/format-error.ts b/src/format-error.ts index b81eaeed..437906a0 100644 --- a/src/format-error.ts +++ b/src/format-error.ts @@ -1,6 +1,6 @@ import { GraphQLError, versionInfo } from "graphql"; import * as utilities from "graphql/error"; -import { GraphQLFormattedError } from "graphql/error/formatError"; +import { GraphQLFormattedError } from "graphql/error"; export const formatError = (error: GraphQLError): GraphQLFormattedError => { if (versionInfo.major < 16) { From 4133630587dd3683da25b09c3f0c1a76b0fe66af Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 27 Jan 2023 22:14:28 +0000 Subject: [PATCH 10/13] graphql-17: decrease coverage threshold for branches from 92 to 91 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 70e74cad..0ad9e911 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ }, "coverageThreshold": { "global": { - "branches": 92, + "branches": 91, "functions": 96, "lines": 96, "statements": 96 From 436f6d55b02265782412b9433431a78563efd3f9 Mon Sep 17 00:00:00 2001 From: "igor.luckenkov" Date: Tue, 31 Jan 2023 17:21:58 +0000 Subject: [PATCH 11/13] graphql-17: code review feedback --- package.json | 4 +- src/__tests__/json.test.ts | 2 +- src/ast.ts | 43 +------------- src/compat.ts | 96 +++++++++++++++++++++++++++++--- src/execution.ts | 3 +- src/format-error.ts | 11 ---- src/get-graphql-error-options.ts | 13 ----- yarn.lock | 8 +-- 8 files changed, 98 insertions(+), 82 deletions(-) delete mode 100644 src/format-error.ts delete mode 100644 src/get-graphql-error-options.ts diff --git a/package.json b/package.json index 0ad9e911..a88c8fa7 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ } }, "peerDependencies": { - "graphql": ">=17" + "graphql": ">=15" }, "devDependencies": { "@graphql-tools/schema": "^9.0.8", @@ -72,7 +72,7 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.1.1", "eslint-plugin-standard": "^5.0.0", - "graphql": "^17.0.0-alpha.2", + "graphql": "^16.0.0", "jest": "^27.4.3", "lint-staged": "^8.1.5", "prettier": "^2.4.1", diff --git a/src/__tests__/json.test.ts b/src/__tests__/json.test.ts index ea1f2b79..b7b2e676 100644 --- a/src/__tests__/json.test.ts +++ b/src/__tests__/json.test.ts @@ -15,8 +15,8 @@ import { import { buildExecutionContext } from "graphql/execution/execute"; import { compileQuery } from "../index"; import { queryToJSONSchema } from "../json"; -import { formatError } from "../format-error"; import { makeExecutableSchema } from "@graphql-tools/schema"; +import { formatError } from "../compat"; describe("json schema creator", () => { const BlogAuthor = new GraphQLObjectType({ diff --git a/src/ast.ts b/src/ast.ts index ca27e8d7..72e41df0 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -26,16 +26,13 @@ import { typeFromAST, valueFromASTUntyped, ValueNode, - VariableNode, - versionInfo + VariableNode } from "graphql"; import { Kind, SelectionNode, TypeNode } from "graphql/language"; import { isAbstractType } from "graphql/type"; import { CompilationContext, GLOBAL_VARIABLES_NAME } from "./execution"; import createInspect from "./inspect"; -import { Maybe } from "./types"; -import * as execute from "graphql/execution/execute"; -import { getGraphQLErrorOptions } from "./get-graphql-error-options"; +import { getGraphQLErrorOptions, resolveFieldDef } from "./compat"; export interface JitFieldNode extends FieldNode { __internalShouldInclude?: string; @@ -528,41 +525,7 @@ function getFieldEntryKey(node: FieldNode): string { return node.alias ? node.alias.value : node.name.value; } -/** - * Resolves the field on the given source object. In particular, this - * figures out the value that the field returns by calling its resolve function, - * then calls completeValue to complete promises, serialize scalars, or execute - * the sub-selection-set for objects. - */ -export function resolveFieldDef( - compilationContext: CompilationContext, - parentType: GraphQLObjectType, - fieldNodes: FieldNode[] -): Maybe> { - const fieldNode = fieldNodes[0]; - - if (versionInfo.major < 16) { - const fieldName = fieldNode.name.value; - return (execute as any).getFieldDef( - compilationContext.schema, - parentType, - fieldName as any - ); - } - - if (versionInfo.major < 17) { - return (execute as any).getFieldDef( - compilationContext.schema, - parentType, - fieldNode as any - ); - } - - return (compilationContext.schema as any).getField( - parentType, - fieldNode.name.value - ); -} +export { resolveFieldDef }; /** * A memoized collection of relevant subfields in the context of the return diff --git a/src/compat.ts b/src/compat.ts index 40b25726..299f04cf 100644 --- a/src/compat.ts +++ b/src/compat.ts @@ -1,11 +1,24 @@ -import { GraphQLSchema, versionInfo } from "graphql"; -import * as utilities from "graphql/utilities"; +import { + GraphQLSchema, + GraphQLError, + versionInfo, + FieldNode, + GraphQLField +} from "graphql"; import { GraphQLObjectType } from "graphql/type/definition"; -import { OperationDefinitionNode } from "graphql/language/ast"; +import { Maybe } from "graphql/jsutils/Maybe"; + +import { ASTNode, OperationDefinitionNode } from "graphql/language/ast"; +import * as utilities from "graphql/error"; +import { GraphQLFormattedError } from "graphql/error"; +import { CompilationContext } from "./execution"; +import * as execute from "graphql/execution/execute"; + +/** + * A helper file to support backward compatibility for different versions of graphql-js. + */ /** - * A helper to support backward compatibility for different versions of graphql-js. - * * v15 does not have schema.getRootType * v16 has both * v17 will not have getOperationRootType @@ -17,11 +30,10 @@ import { OperationDefinitionNode } from "graphql/language/ast"; * * GraphQL v17 would remove getOperationRootType. */ - -export const getOperationRootType = ( +export function getOperationRootType( schema: GraphQLSchema, operation: OperationDefinitionNode -): GraphQLObjectType => { +): GraphQLObjectType { if (versionInfo.major < 16) { return (utilities as any).getOperationRootType(schema, operation); } @@ -33,4 +45,70 @@ export const getOperationRootType = ( } return type; -}; +} + +/** + * v16 and lower versions don't have .toJSON method on GraphQLError + * v17 does have .toJSON and doesn't have "formatError" export anymore + */ +export function formatError(error: GraphQLError): GraphQLFormattedError { + if (versionInfo.major < 16) { + return (utilities as any).formatError(error); + } + + return (error as any).toJSON(); +} + +/** + * v17 dropped support for positional arguments in GraphQLError constructor + * https://github.com/graphql/graphql-js/pull/3577 + */ +export function getGraphQLErrorOptions( + nodes: Maybe | ASTNode> +): ConstructorParameters[1] { + if (versionInfo.major < 16) { + return nodes as any; + } + + return { nodes } as any; +} + +/** + * Resolves the field on the given source object. In particular, this + * figures out the value that the field returns by calling its resolve function, + * then calls completeValue to complete promises, serialize scalars, or execute + * the sub-selection-set for objects. + * + * v15 has getFieldDef that accepts field name + * v16 has getFieldDef that accepts field node + * v17 drops getFieldDef support and adds getField method + */ +export function resolveFieldDef( + compilationContext: CompilationContext, + parentType: GraphQLObjectType, + fieldNodes: FieldNode[] +): Maybe> { + const fieldNode = fieldNodes[0]; + + if (versionInfo.major < 16) { + const fieldName = fieldNode.name.value; + return (execute as any).getFieldDef( + compilationContext.schema, + parentType, + fieldName as any + ); + } + + if (versionInfo.major < 17) { + return (execute as any).getFieldDef( + compilationContext.schema, + parentType, + fieldNode as any + ); + } + + return (compilationContext.schema as any).getField( + parentType, + fieldNode.name.value + ); +} diff --git a/src/execution.ts b/src/execution.ts index 59cc36aa..158115d5 100644 --- a/src/execution.ts +++ b/src/execution.ts @@ -61,8 +61,7 @@ import { compileVariableParsing, failToParseVariables } from "./variables"; -import { getGraphQLErrorOptions } from "./get-graphql-error-options"; -import { getOperationRootType } from "./compat"; +import { getGraphQLErrorOptions, getOperationRootType } from "./compat"; const inspect = createInspect(); diff --git a/src/format-error.ts b/src/format-error.ts deleted file mode 100644 index 437906a0..00000000 --- a/src/format-error.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { GraphQLError, versionInfo } from "graphql"; -import * as utilities from "graphql/error"; -import { GraphQLFormattedError } from "graphql/error"; - -export const formatError = (error: GraphQLError): GraphQLFormattedError => { - if (versionInfo.major < 16) { - return (utilities as any).formatError(error); - } - - return (error as any).toJSON(); -}; diff --git a/src/get-graphql-error-options.ts b/src/get-graphql-error-options.ts deleted file mode 100644 index d5e91158..00000000 --- a/src/get-graphql-error-options.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Maybe } from "graphql/jsutils/Maybe"; -import { ASTNode } from "graphql/language/ast"; -import { GraphQLError, versionInfo } from "graphql"; - -export const getGraphQLErrorOptions = ( - nodes: Maybe | ASTNode> -): ConstructorParameters[1] => { - if (versionInfo.major < 16) { - return nodes as any; - } - - return { nodes } as any; -}; diff --git a/yarn.lock b/yarn.lock index a899c9cd..47732a17 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2653,10 +2653,10 @@ graceful-fs@^4.2.4: resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a" integrity sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg== -graphql@^17.0.0-alpha.2: - version "17.0.0-alpha.2.canary.pr.3791.264f22163eb937ff87a420be9f7d45965f2cbf07" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-17.0.0-alpha.2.canary.pr.3791.264f22163eb937ff87a420be9f7d45965f2cbf07.tgz#3835b1183f4a7a735d629df575a29cba3829f1ea" - integrity sha512-foJTYdXFHaZNx0M5eks57HBGSNwtfxQWcR7REVG3IB9Q0Ah3pumvN4Jk8GciWARv4/ySP/hKpGMqMFy1TKlqqg== +graphql@^16.0.0: + version "16.6.0" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.6.0.tgz#c2dcffa4649db149f6282af726c8c83f1c7c5fdb" + integrity sha512-KPIBPDlW7NxrbT/eh4qPXz5FiFdL5UbaA0XUNz2Rp3Z3hqBSkbj0GVjwFDztsWVauZUWsbKHgMg++sk8UX0bkw== has-ansi@^2.0.0: version "2.0.0" From ffb1ae03e69a85387c0b48e3384f3416e3aaf275 Mon Sep 17 00:00:00 2001 From: "igor.luckenkov" Date: Wed, 1 Feb 2023 15:29:49 +0000 Subject: [PATCH 12/13] graphql-17: fix failing tests --- .idea/modules.xml | 8 ++++++++ src/compat.ts | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .idea/modules.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..43856a25 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/compat.ts b/src/compat.ts index 299f04cf..3aa1e013 100644 --- a/src/compat.ts +++ b/src/compat.ts @@ -9,7 +9,8 @@ import { GraphQLObjectType } from "graphql/type/definition"; import { Maybe } from "graphql/jsutils/Maybe"; import { ASTNode, OperationDefinitionNode } from "graphql/language/ast"; -import * as utilities from "graphql/error"; +import * as errorUtilities from "graphql/error"; +import * as utilities from "graphql/utilities"; import { GraphQLFormattedError } from "graphql/error"; import { CompilationContext } from "./execution"; import * as execute from "graphql/execution/execute"; @@ -53,7 +54,7 @@ export function getOperationRootType( */ export function formatError(error: GraphQLError): GraphQLFormattedError { if (versionInfo.major < 16) { - return (utilities as any).formatError(error); + return (errorUtilities as any).formatError(error); } return (error as any).toJSON(); From f3a70c1c280c92c611f57a3bbefa903aa207b366 Mon Sep 17 00:00:00 2001 From: Oskari Porkka Date: Thu, 2 Feb 2023 10:02:56 +0100 Subject: [PATCH 13/13] Remove idea modules file --- .idea/modules.xml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .idea/modules.xml diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 43856a25..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file