Skip to content

Commit

Permalink
Getting ready for v17 (#4470)
Browse files Browse the repository at this point in the history
* Testing alpha in CI

* ..

* ...

* Fix GraphQL v17 incompatibility issues

* Update changeset

* Fix build

* Fix TS

* ...

* ..

* Go

* Fix TS

* Update peer dependencies
  • Loading branch information
ardatan committed May 20, 2022
1 parent f890605 commit da7ad43
Show file tree
Hide file tree
Showing 50 changed files with 261 additions and 201 deletions.
6 changes: 6 additions & 0 deletions .changeset/rare-schools-judge.md
@@ -0,0 +1,6 @@
---
'@graphql-tools/links': patch
'@graphql-tools/utils': patch
---

Fix GraphQL v17 incompatibility issues and introduce `createGraphQLError` helper function for backwards compatibility.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Expand Up @@ -77,6 +77,7 @@ jobs:
- 14
- 15
- 16
- '17.0.0-alpha.1'
steps:
- name: Checkout Master
uses: actions/checkout@v3
Expand Down Expand Up @@ -117,6 +118,7 @@ jobs:
- 14
- 15
- 16
- '17.0.0-alpha.1'
include:
- node-version: 14
os: windows-latest
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Expand Up @@ -15,4 +15,5 @@ module.exports = {
moduleNameMapper: pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: `${ROOT_DIR}/` }),
collectCoverage: false,
cacheDirectory: resolve(ROOT_DIR, `${CI ? '' : 'node_modules/'}.cache/jest`),
transformIgnorePatterns: ['node_modules/(?!graphql)'],
};
2 changes: 1 addition & 1 deletion packages/batch-delegate/package.json
Expand Up @@ -26,7 +26,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"buildOptions": {
"input": "./src/index.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/batch-execute/package.json
Expand Up @@ -26,7 +26,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"buildOptions": {
"input": "./src/index.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/delegate/package.json
Expand Up @@ -26,7 +26,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"buildOptions": {
"input": "./src/index.ts"
Expand Down
16 changes: 8 additions & 8 deletions packages/delegate/tests/errors.test.ts
@@ -1,20 +1,14 @@
import { GraphQLError, GraphQLResolveInfo, locatedError, graphql, OperationTypeNode } from 'graphql';

import { makeExecutableSchema } from '@graphql-tools/schema';
import { ExecutionResult } from '@graphql-tools/utils';
import { createGraphQLError, ExecutionResult } from '@graphql-tools/utils';
import { stitchSchemas } from '@graphql-tools/stitch';

import { checkResultAndHandleErrors } from '../src/checkResultAndHandleErrors';
import { UNPATHED_ERRORS_SYMBOL } from '../src/symbols';
import { getUnpathedErrors } from '../src/mergeFields';
import { delegateToSchema, defaultMergedResolver, DelegationContext } from '../src';

class ErrorWithExtensions extends GraphQLError {
constructor(message: string, code: string) {
super(message, null as any, null, null, null, null, { code });
}
}

describe('Errors', () => {
describe('getUnpathedErrors', () => {
test('should return all unpathed errors', () => {
Expand Down Expand Up @@ -61,7 +55,13 @@ describe('Errors', () => {

test('persists single error with extensions', () => {
const result = {
errors: [new ErrorWithExtensions('Test error', 'UNAUTHENTICATED')],
errors: [
createGraphQLError('Test error', {
extensions: {
code: 'UNAUTHENTICATED',
},
}),
],
};
try {
checkResultAndHandleErrors(result, {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-tag-pluck/package.json
Expand Up @@ -26,7 +26,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"dependencies": {
"@babel/parser": "^7.16.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-tools/package.json
Expand Up @@ -26,7 +26,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"optionalDependencies": {
"@apollo/client": "~3.2.5 || ~3.3.0 || ~3.4.0 || ~3.5.0 || ~3.6.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/import/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-transform/package.json
Expand Up @@ -26,7 +26,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"buildOptions": {
"input": "./src/index.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/links/package.json
Expand Up @@ -26,7 +26,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
"@apollo/client": "~3.2.5 || ~3.3.0 || ~3.4.0 || ~3.5.0 || ~3.6.0"
},
"buildOptions": {
Expand Down
7 changes: 5 additions & 2 deletions packages/links/src/GraphQLUpload.ts
@@ -1,4 +1,5 @@
import { GraphQLScalarType, GraphQLError } from 'graphql';
import { GraphQLScalarType } from 'graphql';
import { createGraphQLError } from '@graphql-tools/utils';

const GraphQLUpload = new GraphQLScalarType({
name: 'Upload',
Expand All @@ -15,7 +16,9 @@ const GraphQLUpload = new GraphQLScalarType({
// serialization requires to support schema stitching
serialize: value => value,
parseLiteral: ast => {
throw new GraphQLError('Upload literal unsupported.', ast);
throw createGraphQLError('Upload scalar literal unsupported', {
nodes: ast,
});
},
});

Expand Down
2 changes: 1 addition & 1 deletion packages/load-files/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"dependencies": {
"globby": "11.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/load/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"devDependencies": {
"graphql-tag": "2.12.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/apollo-engine/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"dependencies": {
"@graphql-tools/utils": "8.6.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/code-file/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"dependencies": {
"@graphql-tools/utils": "8.6.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/git/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"dependencies": {
"@graphql-tools/graphql-tag-pluck": "7.2.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/github/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"dependencies": {
"@graphql-tools/utils": "8.6.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/graphql-file/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"buildOptions": {
"input": "./src/index.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/json-file/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"dependencies": {
"@graphql-tools/utils": "8.6.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/module/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"dependencies": {
"@graphql-tools/utils": "8.6.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/prisma/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"dependencies": {
"@graphql-tools/url-loader": "7.9.22",
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/url/package.json
Expand Up @@ -32,7 +32,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"devDependencies": {
"@envelop/live-query": "3.3.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/merge/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"buildOptions": {
"input": "./src/index.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/mock/package.json
Expand Up @@ -26,7 +26,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"buildOptions": {
"input": "./src/index.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/node-require/package.json
Expand Up @@ -26,7 +26,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"buildOptions": {
"input": "./src/index.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/optimize/package.json
Expand Up @@ -26,7 +26,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"buildOptions": {
"input": "./src/index.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/relay-operation-optimizer/package.json
Expand Up @@ -38,7 +38,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"dependencies": {
"@graphql-tools/utils": "8.6.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/resolvers-composition/package.json
Expand Up @@ -27,7 +27,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"devDependencies": {
"@types/lodash": "4.14.182",
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/package.json
Expand Up @@ -26,7 +26,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"devDependencies": {
"graphql-scalars": "1.17.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/stitch/package.json
Expand Up @@ -26,7 +26,7 @@
"definition": "dist/index.d.ts"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"buildOptions": {
"input": "./src/index.ts"
Expand Down
3 changes: 1 addition & 2 deletions packages/stitch/src/typeFromAST.ts
Expand Up @@ -26,10 +26,9 @@ import {
getDirectiveValues,
GraphQLDeprecatedDirective,
TypeDefinitionNode,
DirectiveLocationEnum,
} from 'graphql';

import { createStub, createNamedStub, Maybe, getDescription } from '@graphql-tools/utils';
import { createStub, createNamedStub, Maybe, getDescription, DirectiveLocationEnum } from '@graphql-tools/utils';

const backcompatOptions = { commentDescriptions: true };

Expand Down

0 comments on commit da7ad43

Please sign in to comment.