Skip to content

Commit

Permalink
add build schema test
Browse files Browse the repository at this point in the history
  • Loading branch information
robrichard committed Jan 9, 2020
1 parent 428edc5 commit fc70b69
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/utilities/__tests__/buildASTSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
GraphQLSkipDirective,
GraphQLIncludeDirective,
GraphQLDeprecatedDirective,
GraphQLStreamDirective,
GraphQLDeferDirective,
} from '../../type/directives';
import {
GraphQLID,
Expand Down Expand Up @@ -247,6 +249,22 @@ describe('Schema Builder', () => {
expect(schema.getDirective('deprecated')).to.not.equal(undefined);
});

it('Adds @stream and @defer when experimental flags are passed to schema', () => {
const schema = buildSchema('type Query', {
experimentalStream: true,
experimentalDefer: true,
});

expect(schema.getDirectives()).to.have.lengthOf(5);
expect(schema.getDirective('stream')).to.equal(GraphQLStreamDirective);
expect(schema.getDirective('defer')).to.equal(GraphQLDeferDirective);
expect(schema.getDirective('skip')).to.equal(GraphQLSkipDirective);
expect(schema.getDirective('include')).to.equal(GraphQLIncludeDirective);
expect(schema.getDirective('deprecated')).to.equal(
GraphQLDeprecatedDirective,
);
});

it('Type modifiers', () => {
const sdl = dedent`
type Query {
Expand Down
2 changes: 2 additions & 0 deletions src/utilities/buildASTSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,7 @@ export function buildSchema(
commentDescriptions: (options && options.commentDescriptions) || false,
assumeValidSDL: (options && options.assumeValidSDL) || false,
assumeValid: (options && options.assumeValid) || false,
experimentalDefer: (options && options.experimentalDefer) || false,
experimentalStream: (options && options.experimentalStream) || false,
});
}

0 comments on commit fc70b69

Please sign in to comment.