diff --git a/packages/apollo-graphql/package.json b/packages/apollo-graphql/package.json index 600148e802..17d6f5f39e 100644 --- a/packages/apollo-graphql/package.json +++ b/packages/apollo-graphql/package.json @@ -16,7 +16,7 @@ "sha.js": "^2.4.11" }, "peerDependencies": { - "graphql": "^14.2.1 || ^15.0.0" + "graphql": "^14.2.1 || ^15.0.0 || ^16.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 370a25a8ef..6ff3f26d04 100644 --- a/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts +++ b/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts @@ -64,6 +64,21 @@ try { // by the version of `graphql` that is available to us. } +// BREAKING AGAIN: PossibleTypeExtensions is finalized into PossibleTypeExtensionsRule in +// graphql 16. For compatible reason, try catch logic for 15 is kept with extra logic for 16. +try { + // Compatible for graphql-js@16 + const PossibleTypeExtensionsRule = + require("graphql").PossibleTypeExtensionsRule; + + if (PossibleTypeExtensionsRule) { + skippedSDLRules.push(PossibleTypeExtensionsRule); + } +} catch (e) { + // No need to fail in this case. Instead, if this validation rule is missing, we will assume its not used + // by the version of `graphql` that is available to us. +} + const sdlRules = specifiedSDLRules.filter( (rule) => !skippedSDLRules.includes(rule) );