Skip to content

Commit fc70b69

Browse files
committed
add build schema test
1 parent 428edc5 commit fc70b69

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/utilities/__tests__/buildASTSchema-test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import {
1616
GraphQLSkipDirective,
1717
GraphQLIncludeDirective,
1818
GraphQLDeprecatedDirective,
19+
GraphQLStreamDirective,
20+
GraphQLDeferDirective,
1921
} from '../../type/directives';
2022
import {
2123
GraphQLID,
@@ -247,6 +249,22 @@ describe('Schema Builder', () => {
247249
expect(schema.getDirective('deprecated')).to.not.equal(undefined);
248250
});
249251

252+
it('Adds @stream and @defer when experimental flags are passed to schema', () => {
253+
const schema = buildSchema('type Query', {
254+
experimentalStream: true,
255+
experimentalDefer: true,
256+
});
257+
258+
expect(schema.getDirectives()).to.have.lengthOf(5);
259+
expect(schema.getDirective('stream')).to.equal(GraphQLStreamDirective);
260+
expect(schema.getDirective('defer')).to.equal(GraphQLDeferDirective);
261+
expect(schema.getDirective('skip')).to.equal(GraphQLSkipDirective);
262+
expect(schema.getDirective('include')).to.equal(GraphQLIncludeDirective);
263+
expect(schema.getDirective('deprecated')).to.equal(
264+
GraphQLDeprecatedDirective,
265+
);
266+
});
267+
250268
it('Type modifiers', () => {
251269
const sdl = dedent`
252270
type Query {

src/utilities/buildASTSchema.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,7 @@ export function buildSchema(
154154
commentDescriptions: (options && options.commentDescriptions) || false,
155155
assumeValidSDL: (options && options.assumeValidSDL) || false,
156156
assumeValid: (options && options.assumeValid) || false,
157+
experimentalDefer: (options && options.experimentalDefer) || false,
158+
experimentalStream: (options && options.experimentalStream) || false,
157159
});
158160
}

0 commit comments

Comments
 (0)