From beb92c6517ee4c6cf2086495e04d29641cef4870 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Fri, 3 Jan 2020 15:47:55 +0200 Subject: [PATCH 01/13] Expand `peerDependencies` ranges to include `graphql@15.0.0-alpha.2`. --- package-lock.json | 4 ++-- packages/apollo-graphql/package.json | 2 +- packages/apollo-language-server/package.json | 2 +- packages/apollo/package.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4c433e30b7..db5238c176 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3420,7 +3420,7 @@ "git-parse": "1.0.3", "git-rev-sync": "1.12.0", "glob": "7.1.5", - "graphql": "14.0.2 - 14.2.0 || ^14.3.1", + "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0-alpha.2", "graphql-tag": "2.10.1", "listr": "0.14.3", "lodash.identity": "3.0.0", @@ -3691,7 +3691,7 @@ "cosmiconfig": "^5.0.6", "dotenv": "^8.0.0", "glob": "^7.1.3", - "graphql": "14.0.2 - 14.2.0 || ^14.3.1", + "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0-alpha.2", "graphql-tag": "^2.10.1", "lodash.debounce": "^4.0.8", "lodash.merge": "^4.6.1", diff --git a/packages/apollo-graphql/package.json b/packages/apollo-graphql/package.json index 4a5eb2507e..5a3acbaeee 100644 --- a/packages/apollo-graphql/package.json +++ b/packages/apollo-graphql/package.json @@ -15,7 +15,7 @@ "lodash.sortby": "^4.7.0" }, "peerDependencies": { - "graphql": "^14.2.1" + "graphql": "^14.2.1 || ^15.0.0-alpha.2" }, "jest": { "preset": "ts-jest", diff --git a/packages/apollo-language-server/package.json b/packages/apollo-language-server/package.json index 88fb69a6aa..9b48060f8f 100644 --- a/packages/apollo-language-server/package.json +++ b/packages/apollo-language-server/package.json @@ -34,7 +34,7 @@ "cosmiconfig": "^5.0.6", "dotenv": "^8.0.0", "glob": "^7.1.3", - "graphql": "14.0.2 - 14.2.0 || ^14.3.1", + "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0-alpha.2", "graphql-tag": "^2.10.1", "lodash.debounce": "^4.0.8", "lodash.merge": "^4.6.1", diff --git a/packages/apollo/package.json b/packages/apollo/package.json index 42886a98ca..f2678f6c5e 100644 --- a/packages/apollo/package.json +++ b/packages/apollo/package.json @@ -54,7 +54,7 @@ "git-parse": "1.0.3", "git-rev-sync": "1.12.0", "glob": "7.1.5", - "graphql": "14.0.2 - 14.2.0 || ^14.3.1", + "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0-alpha.2", "graphql-tag": "2.10.1", "listr": "0.14.3", "lodash.identity": "3.0.0", From 6b5226340a2a2ba7c10281e20b8eb121f0088e7f Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Fri, 3 Jan 2020 16:04:51 +0200 Subject: [PATCH 02/13] Update root `devDependencies` for `graphql` to `15.0.0-alpha.2`. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1c988cbed7..412ec886b4 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "@types/node": "8.10.56", "@types/node-fetch": "2.5.4", "@types/table": "4.0.7", - "graphql": "14.5.7", + "graphql": "15.0.0-alpha.2", "heroku-cli-util": "8.0.12", "husky": "3.1.0", "jest": "24.9.0", From ca1b3b7e308e9a861ad5ec8f6abab3461a51aff4 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Fri, 3 Jan 2020 16:36:24 +0200 Subject: [PATCH 03/13] Change deprecated `introspectionQuery` constant to `getIntrospectionQuery()`. `introspectionQuery` is deprecated in `graphql@15`. The `getIntrospectionQuery` utility has been around since before `0.13`, which is still within our supported peer dependency ranges. Ref: https://github.com/graphql/graphql-js/pull/2125 --- .../apollo/src/commands/client/__tests__/generate.test.ts | 5 +++-- packages/apollo/src/commands/service/__tests__/check.test.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/apollo/src/commands/client/__tests__/generate.test.ts b/packages/apollo/src/commands/client/__tests__/generate.test.ts index 6185056b6b..258b93ccf5 100644 --- a/packages/apollo/src/commands/client/__tests__/generate.test.ts +++ b/packages/apollo/src/commands/client/__tests__/generate.test.ts @@ -4,7 +4,7 @@ import path from "path"; import fs from "fs"; import { test as setup } from "apollo-cli-test"; import { - introspectionQuery, + getIntrospectionQuery, print, execute, buildSchema, @@ -46,7 +46,8 @@ const { // introspection results of a schema, JSON.stringified const fullSchemaJsonString = JSON.stringify( - execute(buildSchema(graphQLSchema), gql(introspectionQuery)).data.__schema + execute(buildSchema(graphQLSchema), gql(getIntrospectionQuery())).data + .__schema ); // to be used for sample js files that contain client side schema definitions diff --git a/packages/apollo/src/commands/service/__tests__/check.test.ts b/packages/apollo/src/commands/service/__tests__/check.test.ts index d27435549f..39896a05bb 100644 --- a/packages/apollo/src/commands/service/__tests__/check.test.ts +++ b/packages/apollo/src/commands/service/__tests__/check.test.ts @@ -113,7 +113,7 @@ function uncaptureApplicationOutput(): string | null { function sdlToIntrospectionQueryResult(schemaSdl: string) { return graphql.graphqlSync( graphql.buildSchema(schemaSdl), - graphql.introspectionQuery + graphql.getIntrospectionQuery() ).data; } From 24db528b71c2b24a45c95c4b75cd479e0291a9a4 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Fri, 3 Jan 2020 16:38:14 +0200 Subject: [PATCH 04/13] Remove references to `introspectionQuery` which is now deprecated. Ref: https://github.com/graphql/graphql-js/pull/2125 --- packages/apollo-language-server/src/providers/schema/file.ts | 2 +- packages/apollo/src/Command.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/apollo-language-server/src/providers/schema/file.ts b/packages/apollo-language-server/src/providers/schema/file.ts index f216c565e1..656877c9a7 100644 --- a/packages/apollo-language-server/src/providers/schema/file.ts +++ b/packages/apollo-language-server/src/providers/schema/file.ts @@ -70,7 +70,7 @@ export class FileSchemaProvider implements GraphQLSchemaProvider { const ext = extname(path); - // an actual introspectionQuery result, convert to DocumentNode + // an actual introspection query result, convert to DocumentNode if (ext === ".json") { const parsed = JSON.parse(result); const __schema = parsed.data diff --git a/packages/apollo/src/Command.ts b/packages/apollo/src/Command.ts index fc3ef34675..4a24c2debd 100644 --- a/packages/apollo/src/Command.ts +++ b/packages/apollo/src/Command.ts @@ -73,7 +73,7 @@ export abstract class ProjectCommand extends Command { return JSON.stringify({ [key]: value }); }, description: - "Additional header to send to server for introspectionQuery. May be used multiple times to add multiple headers. NOTE: The `--endpoint` flag is REQUIRED if using the `--header` flag." + "Additional header to send during introspection. May be used multiple times to add multiple headers. NOTE: The `--endpoint` flag is REQUIRED if using the `--header` flag." }), endpoint: flags.string({ description: "The url of your service" From 71ec6a56e0cbe0bad66221280564837b79da8f2b Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Fri, 3 Jan 2020 16:45:12 +0200 Subject: [PATCH 05/13] Update `graphql` dependency in `package-lock.json`. --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index db5238c176..077d32d22b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8224,9 +8224,9 @@ "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" }, "graphql": { - "version": "14.5.7", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-14.5.7.tgz", - "integrity": "sha512-as410RMJSUFqF8RcH2QWxZ5ioqHzsH9VWnWbaU+UnDXJ/6azMDIYPrtXCBPXd8rlunEVb7W8z6fuUnNHMbFu9A==", + "version": "15.0.0-alpha.2", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.0.0-alpha.2.tgz", + "integrity": "sha512-OwI3D5b168+zbIb0NnjJyKbgonYW/QBACzVNZzdYSlGv5Jid1/UI5C1JEzIUAwWCoOKMuxMufaPmsDeu6vDGDg==", "requires": { "iterall": "^1.2.2" } From 16339038247c298a7b4fc6d89bb1bb288e5baf94 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Fri, 3 Jan 2020 16:59:59 +0200 Subject: [PATCH 06/13] Account for the deprecation of `ValidationContext.prototype.getErrors`. We'll use the new `onError` callback which was introduced in `graphql@14.5.0` by https://github.com/graphql/graphql-js/pull/2074 only if the `getErrors` method that existed prior to that addition no longer exists. --- .../src/errors/validation.ts | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/apollo-language-server/src/errors/validation.ts b/packages/apollo-language-server/src/errors/validation.ts index c9fa38cb4d..e7c23831d2 100644 --- a/packages/apollo-language-server/src/errors/validation.ts +++ b/packages/apollo-language-server/src/errors/validation.ts @@ -51,7 +51,18 @@ export function getValidationErrors( rules: ValidationRule[] = defaultValidationRules ) { const typeInfo = new TypeInfo(schema); - const context = new ValidationContext(schema, document, typeInfo); + + // The 4th argument to `ValidationContext` is an `onError` callback. This was + // introduced by https://github.com/graphql/graphql-js/pull/2074 and first + // published in graphql@14.5.0. It is meant to replace the `getErrors` method + // which was previously used. Since we support versions of graphql older than + // that, it's possible that this callback will not be invoked and we'll need + // to resort to using `getErrors`. Therefore, although we'll collect errors + // via this callback, if `getErrors` is present on the context we create, + // we'll go ahead and use that instead. + const errors: GraphQLError[] = []; + const onError = (err: GraphQLError) => errors.push(err); + const context = new ValidationContext(schema, document, typeInfo, onError); if (fragments) { (context as any)._fragments = fragments; @@ -60,7 +71,14 @@ export function getValidationErrors( const visitors = rules.map(rule => rule(context)); // Visit the whole document with each instance of all provided rules. visit(document, visitWithTypeInfo(typeInfo, visitInParallel(visitors))); - return context.getErrors(); + + // @ts-ignore + // `getErrors` is gone in `graphql@15`, but we still support older versions. + if (typeof context.getErrors === "function") return context.getErrors(); + + // If `getErrors` doesn't exist, we must be on a `graphql@15` or higher, + // so we'll use the errors we collected via the `onError` callback. + return errors; } export function validateQueryDocument( From 2f8b252f83e12f5f12f0ef71be1c285018a22a26 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Fri, 3 Jan 2020 17:03:25 +0200 Subject: [PATCH 07/13] Remove unused import of the now-deprecated `createLexer` method. Even though we were importing it, we don't actually invoke it, however that's more relevant now that it's officially deprecated in `graphql@15`. Ref: https://github.com/graphql/graphql-js/pull/2210 --- packages/apollo-codegen-scala/src/codeGeneration.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/apollo-codegen-scala/src/codeGeneration.ts b/packages/apollo-codegen-scala/src/codeGeneration.ts index 51e52a9c66..d91ca12c7a 100644 --- a/packages/apollo-codegen-scala/src/codeGeneration.ts +++ b/packages/apollo-codegen-scala/src/codeGeneration.ts @@ -48,7 +48,6 @@ import { import { GraphQLType } from "graphql"; import { Property } from "./language"; import { GraphQLCompositeType } from "graphql"; -import { createLexer } from "graphql/language"; export function generateSource(context: LegacyCompilerContext) { const generator = new CodeGenerator(context); From 35277a11c75fa9874327e099b7be6a8ae1f5cf0f Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Fri, 3 Jan 2020 17:07:19 +0200 Subject: [PATCH 08/13] Update snapshots to accommodate inclusion of `@` on directive-related errors. --- .../src/schema/__tests__/buildSchemaFromSDL.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/apollo-graphql/src/schema/__tests__/buildSchemaFromSDL.test.ts b/packages/apollo-graphql/src/schema/__tests__/buildSchemaFromSDL.test.ts index 806e464274..9a812fcebb 100644 --- a/packages/apollo-graphql/src/schema/__tests__/buildSchemaFromSDL.test.ts +++ b/packages/apollo-graphql/src/schema/__tests__/buildSchemaFromSDL.test.ts @@ -282,7 +282,7 @@ type MutationRoot { ` ) ).toThrowErrorMatchingInlineSnapshot( - `"There can be only one directive named \\"something\\"."` + `"There can be only one directive named \\"@something\\"."` ); }); @@ -303,7 +303,7 @@ type MutationRoot { }) ) ).toThrowErrorMatchingInlineSnapshot( - `"Directive \\"something\\" already exists in the schema. It cannot be redefined."` + `"Directive \\"@something\\" already exists in the schema. It cannot be redefined."` ); }); @@ -348,7 +348,7 @@ type MutationRoot { ` ) ).toThrowErrorMatchingInlineSnapshot( - `"Unknown directive \\"something\\"."` + `"Unknown directive \\"@something\\"."` ); }); }); From bfb1accbec8dc2caedae8f74e22ddee2de2fe35e Mon Sep 17 00:00:00 2001 From: Trevor Scheer Date: Mon, 29 Jun 2020 14:38:28 -0700 Subject: [PATCH 09/13] Update branch with current graphql version --- package-lock.json | 18 +++++------------- package.json | 2 +- packages/apollo-graphql/package.json | 2 +- .../src/schema/buildSchemaFromSDL.ts | 1 + packages/apollo-language-server/package.json | 2 +- .../src/project/client.ts | 7 +++---- packages/apollo/package.json | 2 +- 7 files changed, 13 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 077d32d22b..37305b1b58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3420,7 +3420,7 @@ "git-parse": "1.0.3", "git-rev-sync": "1.12.0", "glob": "7.1.5", - "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0-alpha.2", + "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0", "graphql-tag": "2.10.1", "listr": "0.14.3", "lodash.identity": "3.0.0", @@ -3691,7 +3691,7 @@ "cosmiconfig": "^5.0.6", "dotenv": "^8.0.0", "glob": "^7.1.3", - "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0-alpha.2", + "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0", "graphql-tag": "^2.10.1", "lodash.debounce": "^4.0.8", "lodash.merge": "^4.6.1", @@ -8224,12 +8224,9 @@ "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" }, "graphql": { - "version": "15.0.0-alpha.2", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.0.0-alpha.2.tgz", - "integrity": "sha512-OwI3D5b168+zbIb0NnjJyKbgonYW/QBACzVNZzdYSlGv5Jid1/UI5C1JEzIUAwWCoOKMuxMufaPmsDeu6vDGDg==", - "requires": { - "iterall": "^1.2.2" - } + "version": "15.2.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.2.0.tgz", + "integrity": "sha512-tsceRyHfgzZo+ee0YK3o8f0CR0cXAXxRlxoORWFo/CoM1bVy3UXGWeyzBcf+Y6oqPvO27BDmOEVATcunOO/MrQ==" }, "graphql-tag": { "version": "2.10.1", @@ -9267,11 +9264,6 @@ "is-object": "^1.0.1" } }, - "iterall": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.2.2.tgz", - "integrity": "sha512-yynBb1g+RFUPY64fTrFv7nsjRrENBQJaX2UL+2Szc9REFrSNm1rpSXHGzhmAy7a9uv3vlvgBlXnf9RqmPH1/DA==" - }, "java-properties": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/java-properties/-/java-properties-1.0.2.tgz", diff --git a/package.json b/package.json index 412ec886b4..9529d15ff3 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "@types/node": "8.10.56", "@types/node-fetch": "2.5.4", "@types/table": "4.0.7", - "graphql": "15.0.0-alpha.2", + "graphql": "15.2.0", "heroku-cli-util": "8.0.12", "husky": "3.1.0", "jest": "24.9.0", diff --git a/packages/apollo-graphql/package.json b/packages/apollo-graphql/package.json index 5a3acbaeee..4778443fcd 100644 --- a/packages/apollo-graphql/package.json +++ b/packages/apollo-graphql/package.json @@ -15,7 +15,7 @@ "lodash.sortby": "^4.7.0" }, "peerDependencies": { - "graphql": "^14.2.1 || ^15.0.0-alpha.2" + "graphql": "^14.2.1 || ^15.0.0" }, "jest": { "preset": "ts-jest", diff --git a/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts b/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts index 4580837f4c..0ed47c88a9 100644 --- a/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts +++ b/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts @@ -244,6 +244,7 @@ export function addResolversToSchema( newValues[value.name] = { value: newValue, deprecationReason: value.deprecationReason, + isDeprecated: value.isDeprecated, description: value.description, astNode: value.astNode, name: value.name, diff --git a/packages/apollo-language-server/package.json b/packages/apollo-language-server/package.json index 9b48060f8f..6afb65d0bc 100644 --- a/packages/apollo-language-server/package.json +++ b/packages/apollo-language-server/package.json @@ -34,7 +34,7 @@ "cosmiconfig": "^5.0.6", "dotenv": "^8.0.0", "glob": "^7.1.3", - "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0-alpha.2", + "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0", "graphql-tag": "^2.10.1", "lodash.debounce": "^4.0.8", "lodash.merge": "^4.6.1", diff --git a/packages/apollo-language-server/src/project/client.ts b/packages/apollo-language-server/src/project/client.ts index df59d5fa16..72ce6ed8bb 100644 --- a/packages/apollo-language-server/src/project/client.ts +++ b/packages/apollo-language-server/src/project/client.ts @@ -18,12 +18,9 @@ import { FieldNode, ObjectTypeDefinitionNode, GraphQLObjectType, - DefinitionNode, - DirectiveDefinitionNode + DefinitionNode } from "graphql"; import { ValidationRule } from "graphql/validation/ValidationContext"; -import Maybe from "graphql/tsutils/Maybe"; - import { NotificationHandler, DiagnosticSeverity } from "vscode-languageserver"; import { rangeForASTNode } from "../utilities/source"; @@ -50,6 +47,8 @@ import { } from "../diagnostics"; import URI from "vscode-uri"; +type Maybe = null | undefined | T; + function schemaHasASTNodes(schema: GraphQLSchema): boolean { const queryType = schema && schema.getQueryType(); return !!(queryType && queryType.astNode); diff --git a/packages/apollo/package.json b/packages/apollo/package.json index f2678f6c5e..a1945c5acc 100644 --- a/packages/apollo/package.json +++ b/packages/apollo/package.json @@ -54,7 +54,7 @@ "git-parse": "1.0.3", "git-rev-sync": "1.12.0", "glob": "7.1.5", - "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0-alpha.2", + "graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0", "graphql-tag": "2.10.1", "listr": "0.14.3", "lodash.identity": "3.0.0", From f1787f0e880c0f8cd2157b54f331400fd4f12272 Mon Sep 17 00:00:00 2001 From: Trevor Scheer Date: Mon, 29 Jun 2020 15:44:48 -0700 Subject: [PATCH 10/13] Fix usage of isDeprecated --- .../__snapshots__/jsonOutput.ts.snap | 27 ++++++++++++------- .../src/schema/buildSchemaFromSDL.ts | 3 ++- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/apollo-codegen-core/src/__tests__/__snapshots__/jsonOutput.ts.snap b/packages/apollo-codegen-core/src/__tests__/__snapshots__/jsonOutput.ts.snap index 747e859839..8890634635 100644 --- a/packages/apollo-codegen-core/src/__tests__/__snapshots__/jsonOutput.ts.snap +++ b/packages/apollo-codegen-core/src/__tests__/__snapshots__/jsonOutput.ts.snap @@ -49,7 +49,8 @@ exports[`JSON output should generate JSON output for a mutation with an enum and \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"stars\\", @@ -176,7 +177,8 @@ exports[`JSON output should generate JSON output for a query with a fragment spr \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"id\\", @@ -217,7 +219,8 @@ exports[`JSON output should generate JSON output for a query with a fragment spr \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"name\\", @@ -240,7 +243,8 @@ exports[`JSON output should generate JSON output for a query with a fragment spr \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"name\\", @@ -271,7 +275,8 @@ exports[`JSON output should generate JSON output for a query with a fragment spr \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"name\\", @@ -321,7 +326,8 @@ exports[`JSON output should generate JSON output for a query with a nested selec \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"name\\", @@ -343,7 +349,8 @@ exports[`JSON output should generate JSON output for a query with a nested selec \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"name\\", @@ -411,7 +418,8 @@ exports[`JSON output should generate JSON output for a query with an enum variab \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"name\\", @@ -500,7 +508,8 @@ exports[`JSON output should generate JSON output for a subscription 1`] = ` \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"id\\", diff --git a/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts b/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts index 67b56a5473..44a4461d74 100644 --- a/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts +++ b/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts @@ -256,7 +256,8 @@ export function addResolversToSchema( newValues[value.name] = { value: newValue, deprecationReason: value.deprecationReason, - isDeprecated: value.isDeprecated, + // @see https://github.com/graphql/graphql-js/blob/13ab792895c7056186fddee552d0db9776c735a3/src/type/definition.js#L1439 + isDeprecated: value.deprecationReason != null, description: value.description, astNode: value.astNode, name: value.name, From e8d659d0e23039304c91a56ac4d7a0a3732e7f85 Mon Sep 17 00:00:00 2001 From: Trevor Scheer Date: Mon, 29 Jun 2020 15:57:35 -0700 Subject: [PATCH 11/13] Revert "Fix usage of isDeprecated" This reverts commit f1787f0e880c0f8cd2157b54f331400fd4f12272. --- .../__snapshots__/jsonOutput.ts.snap | 27 +++++++------------ .../src/schema/buildSchemaFromSDL.ts | 3 +-- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/packages/apollo-codegen-core/src/__tests__/__snapshots__/jsonOutput.ts.snap b/packages/apollo-codegen-core/src/__tests__/__snapshots__/jsonOutput.ts.snap index 8890634635..747e859839 100644 --- a/packages/apollo-codegen-core/src/__tests__/__snapshots__/jsonOutput.ts.snap +++ b/packages/apollo-codegen-core/src/__tests__/__snapshots__/jsonOutput.ts.snap @@ -49,8 +49,7 @@ exports[`JSON output should generate JSON output for a mutation with an enum and \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false, - \\"isDeprecated\\": false + \\"isConditional\\": false }, { \\"responseName\\": \\"stars\\", @@ -177,8 +176,7 @@ exports[`JSON output should generate JSON output for a query with a fragment spr \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false, - \\"isDeprecated\\": false + \\"isConditional\\": false }, { \\"responseName\\": \\"id\\", @@ -219,8 +217,7 @@ exports[`JSON output should generate JSON output for a query with a fragment spr \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false, - \\"isDeprecated\\": false + \\"isConditional\\": false }, { \\"responseName\\": \\"name\\", @@ -243,8 +240,7 @@ exports[`JSON output should generate JSON output for a query with a fragment spr \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false, - \\"isDeprecated\\": false + \\"isConditional\\": false }, { \\"responseName\\": \\"name\\", @@ -275,8 +271,7 @@ exports[`JSON output should generate JSON output for a query with a fragment spr \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false, - \\"isDeprecated\\": false + \\"isConditional\\": false }, { \\"responseName\\": \\"name\\", @@ -326,8 +321,7 @@ exports[`JSON output should generate JSON output for a query with a nested selec \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false, - \\"isDeprecated\\": false + \\"isConditional\\": false }, { \\"responseName\\": \\"name\\", @@ -349,8 +343,7 @@ exports[`JSON output should generate JSON output for a query with a nested selec \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false, - \\"isDeprecated\\": false + \\"isConditional\\": false }, { \\"responseName\\": \\"name\\", @@ -418,8 +411,7 @@ exports[`JSON output should generate JSON output for a query with an enum variab \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false, - \\"isDeprecated\\": false + \\"isConditional\\": false }, { \\"responseName\\": \\"name\\", @@ -508,8 +500,7 @@ exports[`JSON output should generate JSON output for a subscription 1`] = ` \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false, - \\"isDeprecated\\": false + \\"isConditional\\": false }, { \\"responseName\\": \\"id\\", diff --git a/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts b/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts index 44a4461d74..67b56a5473 100644 --- a/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts +++ b/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts @@ -256,8 +256,7 @@ export function addResolversToSchema( newValues[value.name] = { value: newValue, deprecationReason: value.deprecationReason, - // @see https://github.com/graphql/graphql-js/blob/13ab792895c7056186fddee552d0db9776c735a3/src/type/definition.js#L1439 - isDeprecated: value.deprecationReason != null, + isDeprecated: value.isDeprecated, description: value.description, astNode: value.astNode, name: value.name, From e9db99de5b5a4e128aee7409c5c58d7f4f5833ed Mon Sep 17 00:00:00 2001 From: Trevor Scheer Date: Thu, 2 Jul 2020 14:15:11 -0700 Subject: [PATCH 12/13] Update usage of GraphQLEnumValue to GraphQLEnumValueConfig --- package-lock.json | 20 ++++++++++++++ .../__snapshots__/jsonOutput.ts.snap | 27 ++++++++++++------- .../src/schema/buildSchemaFromSDL.ts | 7 +++-- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5652c8ccdc..c6ccf66938 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,26 @@ "lodash.xorby": "^4.7.0" }, "dependencies": { + "apollo-env": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/apollo-env/-/apollo-env-0.6.5.tgz", + "integrity": "sha512-jeBUVsGymeTHYWp3me0R2CZRZrFeuSZeICZHCeRflHTfnQtlmbSXdy5E0pOyRM9CU4JfQkKDC98S1YglQj7Bzg==", + "requires": { + "@types/node-fetch": "2.5.7", + "core-js": "^3.0.1", + "node-fetch": "^2.2.0", + "sha.js": "^2.4.11" + } + }, + "apollo-graphql": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/apollo-graphql/-/apollo-graphql-0.4.5.tgz", + "integrity": "sha512-0qa7UOoq7E71kBYE7idi6mNQhHLVdMEDInWk6TNw3KsSWZE2/I68gARP84Mj+paFTO5NYuw1Dht66PVX76Cc2w==", + "requires": { + "apollo-env": "^0.6.5", + "lodash.sortby": "^4.7.0" + } + }, "apollo-server-env": { "version": "2.4.5", "resolved": "https://registry.npmjs.org/apollo-server-env/-/apollo-server-env-2.4.5.tgz", diff --git a/packages/apollo-codegen-core/src/__tests__/__snapshots__/jsonOutput.ts.snap b/packages/apollo-codegen-core/src/__tests__/__snapshots__/jsonOutput.ts.snap index 747e859839..8890634635 100644 --- a/packages/apollo-codegen-core/src/__tests__/__snapshots__/jsonOutput.ts.snap +++ b/packages/apollo-codegen-core/src/__tests__/__snapshots__/jsonOutput.ts.snap @@ -49,7 +49,8 @@ exports[`JSON output should generate JSON output for a mutation with an enum and \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"stars\\", @@ -176,7 +177,8 @@ exports[`JSON output should generate JSON output for a query with a fragment spr \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"id\\", @@ -217,7 +219,8 @@ exports[`JSON output should generate JSON output for a query with a fragment spr \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"name\\", @@ -240,7 +243,8 @@ exports[`JSON output should generate JSON output for a query with a fragment spr \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"name\\", @@ -271,7 +275,8 @@ exports[`JSON output should generate JSON output for a query with a fragment spr \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"name\\", @@ -321,7 +326,8 @@ exports[`JSON output should generate JSON output for a query with a nested selec \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"name\\", @@ -343,7 +349,8 @@ exports[`JSON output should generate JSON output for a query with a nested selec \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"name\\", @@ -411,7 +418,8 @@ exports[`JSON output should generate JSON output for a query with an enum variab \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"name\\", @@ -500,7 +508,8 @@ exports[`JSON output should generate JSON output for a subscription 1`] = ` \\"responseName\\": \\"__typename\\", \\"fieldName\\": \\"__typename\\", \\"type\\": \\"String!\\", - \\"isConditional\\": false + \\"isConditional\\": false, + \\"isDeprecated\\": false }, { \\"responseName\\": \\"id\\", diff --git a/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts b/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts index 67b56a5473..274937091e 100644 --- a/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts +++ b/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts @@ -18,7 +18,7 @@ import { isAbstractType, isScalarType, isEnumType, - GraphQLEnumValue + GraphQLEnumValueConfig } from "graphql"; import { validateSDL } from "graphql/validation/validate"; import { isDocumentNode, isNode } from "../utilities/graphql"; @@ -247,19 +247,18 @@ export function addResolversToSchema( if (isEnumType(type)) { const values = type.getValues(); - const newValues: { [key: string]: GraphQLEnumValue } = {}; + const newValues: { [key: string]: GraphQLEnumValueConfig } = {}; values.forEach(value => { let newValue = (fieldConfigs as any)[value.name]; if (newValue === undefined) { newValue = value.name; } + newValues[value.name] = { value: newValue, deprecationReason: value.deprecationReason, - isDeprecated: value.isDeprecated, description: value.description, astNode: value.astNode, - name: value.name, extensions: undefined }; }); From 94ecea8ef5148e2b23d32c4d44148b45e8f3fd0f Mon Sep 17 00:00:00 2001 From: Trevor Scheer Date: Tue, 7 Jul 2020 14:15:07 -0700 Subject: [PATCH 13/13] Update changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffec0cb148..96dc92f3ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Upcoming - `apollo` - - + - Add support for graphql version ^15 [#1743](https://github.com/apollographql/apollo-tooling/pull/1743) - `apollo-codegen-flow` - - `apollo-codegen-scala` @@ -17,9 +17,10 @@ - `apollo-env` - - `apollo-graphql` - - + - Add support for graphql version ^15 [#1743](https://github.com/apollographql/apollo-tooling/pull/1743) - `apollo-language-server` - Fix definition navigation for vscode using localSchemaFile [#1996](https://github.com/apollographql/apollo-tooling/pull/1996) + - Add support for graphql version ^15 [#1743](https://github.com/apollographql/apollo-tooling/pull/1743) - `apollo-tools` - - `vscode-apollo`