Skip to content

Commit

Permalink
Conditionally import PossibleTypeExtensions validation rule
Browse files Browse the repository at this point in the history
  • Loading branch information
oguimbal committed May 6, 2020
1 parent 09ac584 commit aecb53e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/apollo-graphql/src/schema/buildSchemaFromSDL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,26 @@ 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 {
typeDefs: DocumentNode;
resolvers?: GraphQLResolverMap<any>;
}

const skippedSDLRules = [
PossibleTypeExtensions,
KnownTypeNamesRule,
UniqueDirectivesPerLocationRule
];
const skippedSDLRules = [KnownTypeNamesRule, UniqueDirectivesPerLocationRule];

// Currently, this PossibleTypeExtensions rule is experimental and thus not
// exposed directly from the rules module above. This may change in the future!
// Additionally, it does not exist in prior graphql versions. Thus this try/catch.
try {
const {
PossibleTypeExtensions
} = require("graphql/validation/rules/PossibleTypeExtensions");
skippedSDLRules.push(PossibleTypeExtensions);
} catch (e) {
// ignore this error
}

const sdlRules = specifiedSDLRules.filter(
rule => !skippedSDLRules.includes(rule)
Expand Down

0 comments on commit aecb53e

Please sign in to comment.