Skip to content

Commit a62bdf5

Browse files
committed
Use object equality when filtering rules in buildSchemaFromSDL
Similar in spirit to apollographql/apollo-server#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: apollographql/apollo-server#3335
1 parent 0ddfc0a commit a62bdf5

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ import { isDocumentNode, isNode } from "../utilities/graphql";
2525
import { GraphQLResolverMap } from "./resolverMap";
2626
import { GraphQLSchemaValidationError } from "./GraphQLSchemaValidationError";
2727
import { specifiedSDLRules } from "graphql/validation/specifiedRules";
28+
import {
29+
KnownTypeNamesRule,
30+
UniqueDirectivesPerLocationRule
31+
} from "graphql/validation";
32+
// Currently, this PossibleTypeExtensions rule is experimental and thus not
33+
// exposed directly from the rules module above. This may change in the future!
34+
import { PossibleTypeExtensions } from "graphql/validation/rules/PossibleTypeExtensions";
2835
import { mapValues, isNotNullOrUndefined } from "apollo-env";
2936

3037
export interface GraphQLSchemaModule {
@@ -33,13 +40,13 @@ export interface GraphQLSchemaModule {
3340
}
3441

3542
const skippedSDLRules = [
36-
"PossibleTypeExtensions",
37-
"KnownTypeNames",
38-
"UniqueDirectivesPerLocation"
43+
PossibleTypeExtensions,
44+
KnownTypeNamesRule,
45+
UniqueDirectivesPerLocationRule
3946
];
4047

4148
const sdlRules = specifiedSDLRules.filter(
42-
rule => !skippedSDLRules.includes(rule.name)
49+
rule => !skippedSDLRules.includes(rule)
4350
);
4451

4552
export function modulesFromSDL(

0 commit comments

Comments
 (0)