From a62bdf583de1954ce17f0887a1afe7b4db031fcd Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Wed, 25 Sep 2019 14:26:17 +0300 Subject: [PATCH 1/2] Use object equality when filtering rules in `buildSchemaFromSDL` Similar in spirit to https://github.com/apollographql/apollo-server/pull/3338. The technique previously used for removing rules from the standard `specifiedRules` was leveraging a check on `Function.prototype.name`, rather than doing direct object equality. While that does generally work, thanks to the more recent standardization of `Function.prototype.name`, it still breaks down under some of the more aggressive minification techniques since a function's name is not guaranteed to remain the same. Fixes: https://github.com/apollographql/apollo-server/issues/3335 --- .../src/schema/buildSchemaFromSDL.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts b/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts index 308803d2ed..2caae67a47 100644 --- a/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts +++ b/packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts @@ -25,6 +25,13 @@ import { isDocumentNode, isNode } from "../utilities/graphql"; import { GraphQLResolverMap } from "./resolverMap"; import { GraphQLSchemaValidationError } from "./GraphQLSchemaValidationError"; import { specifiedSDLRules } from "graphql/validation/specifiedRules"; +import { + KnownTypeNamesRule, + UniqueDirectivesPerLocationRule +} from "graphql/validation"; +// Currently, this PossibleTypeExtensions rule is experimental and thus not +// exposed directly from the rules module above. This may change in the future! +import { PossibleTypeExtensions } from "graphql/validation/rules/PossibleTypeExtensions"; import { mapValues, isNotNullOrUndefined } from "apollo-env"; export interface GraphQLSchemaModule { @@ -33,13 +40,13 @@ export interface GraphQLSchemaModule { } const skippedSDLRules = [ - "PossibleTypeExtensions", - "KnownTypeNames", - "UniqueDirectivesPerLocation" + PossibleTypeExtensions, + KnownTypeNamesRule, + UniqueDirectivesPerLocationRule ]; const sdlRules = specifiedSDLRules.filter( - rule => !skippedSDLRules.includes(rule.name) + rule => !skippedSDLRules.includes(rule) ); export function modulesFromSDL( From 58946c327563f63bcf45b9b6732a1a5c488a26f9 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Tue, 1 Oct 2019 10:30:14 +0300 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad9dab5a2..8eb43e1e78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ - `apollo-env` - - `apollo-graphql` - - + - Use reference-equality, rather than `Function.prototype.name` string comparison, when omitting validation rules within `buildSchemaFromSDL`. [#1551](https://github.com/apollographql/apollo-tooling/pull/1551) - `apollo-language-server` - - `apollo-tools`