Skip to content

Commit a8efd47

Browse files
committed
Add compatible logic for graphql@16
1 parent 4f3ac25 commit a8efd47

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

packages/apollo-graphql/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"sha.js": "^2.4.11"
1717
},
1818
"peerDependencies": {
19-
"graphql": "^14.2.1 || ^15.0.0"
19+
"graphql": "^14.2.1 || ^15.0.0 || ^16.0.0"
2020
},
2121
"jest": {
2222
"preset": "ts-jest",

packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,22 @@ const skippedSDLRules: ValidationRule[] = [
5353
// Currently, this PossibleTypeExtensions rule is experimental and thus not
5454
// exposed directly from the rules module above. This may change in the future!
5555
// Additionally, it does not exist in prior graphql versions. Thus this try/catch.
56+
//
57+
// BREAKING AGAIN: PossibleTypeExtensions is finilized into PossibleTypeExtensionsRule in
58+
// graphql 16. For compatible reason, try catch logic for 15 is kept with extra logic for 16.
5659
try {
60+
// Compatible for graphql@15
5761
const PossibleTypeExtensions: typeof import("graphql/validation/rules/PossibleTypeExtensions").PossibleTypeExtensions = require("graphql/validation/rules/PossibleTypeExtensions")
5862
.PossibleTypeExtensions;
63+
64+
// Compatible for graphql@16
65+
const PossibleTypeExtensionsRule = require("graphql")
66+
.PossibleTypeExtensionsRule;
67+
5968
if (PossibleTypeExtensions) {
6069
skippedSDLRules.push(PossibleTypeExtensions);
70+
} else if (PossibleTypeExtensionsRule) {
71+
skippedSDLRules.push(PossibleTypeExtensionsRule);
6172
}
6273
} catch (e) {
6374
// No need to fail in this case. Instead, if this validation rule is missing, we will assume its not used

0 commit comments

Comments
 (0)