Skip to content

Commit dd344e8

Browse files
committed
fix feature flags
1 parent 7f8e2f0 commit dd344e8

File tree

3 files changed

+11
-28
lines changed

3 files changed

+11
-28
lines changed

src/__tests__/starWarsDeferredQuery-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313

1414
describe('Star Wars Query Deferred Tests', () => {
1515
describe('Compatibility', () => {
16-
it('Can disable @defer and return would-be deferred data as part of initial result', async () => {
16+
it('Should throw error if using @defer without enabling in the schema', async () => {
1717
const query = `
1818
query HeroNameQuery {
1919
hero {

src/__tests__/starWarsStreamQuery-test.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313

1414
describe('Star Wars Query Stream Tests', () => {
1515
describe('Compatibility', () => {
16-
it('Can disable @stream and return would-be streamed data as part of initial result', async () => {
16+
it('Should throw error if using @stream without enabling in the schema', async () => {
1717
const query = `
1818
query HeroFriendsQuery {
1919
hero {
@@ -26,24 +26,12 @@ describe('Star Wars Query Stream Tests', () => {
2626
`;
2727
const result = await graphql(StarWarsSchema, query);
2828
expect(result).to.deep.equal({
29-
data: {
30-
hero: {
31-
friends: [
32-
{
33-
id: '1000',
34-
name: 'Luke Skywalker',
35-
},
36-
{
37-
id: '1002',
38-
name: 'Han Solo',
39-
},
40-
{
41-
id: '1003',
42-
name: 'Leia Organa',
43-
},
44-
],
29+
errors: [
30+
{
31+
message: 'Unknown directive "@stream".',
32+
locations: [{ line: 4, column: 21 }],
4533
},
46-
},
34+
],
4735
});
4836
});
4937
it('Can disable @stream using if argument', async () => {

src/type/schema.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ export class GraphQLSchema {
137137
// Used as a cache for validateSchema().
138138
__validationErrors: ?$ReadOnlyArray<GraphQLError>;
139139
// Referenced by execute()
140-
__experimentalDefer: boolean;
141-
__experimentalStream: boolean;
140+
__experimentalDefer: ?boolean;
141+
__experimentalStream: ?boolean;
142142

143143
constructor(config: $ReadOnly<GraphQLSchemaConfig>): void {
144144
// If this schema was built from a source known to be valid, then it may be
@@ -166,25 +166,20 @@ export class GraphQLSchema {
166166
this.astNode = config.astNode;
167167
this.extensionASTNodes = config.extensionASTNodes;
168168

169-
this.__experimentalStream = config.experimentalStream || false;
170169
this._queryType = config.query;
171170
this._mutationType = config.mutation;
172171
this._subscriptionType = config.subscription;
173172
// Provide specified directives (e.g. @include and @skip) by default.
174173
this._directives = config.directives || specifiedDirectives;
175174

176-
if (config.__experimentalDefer) {
177-
this.____experimentalDefer = true;
175+
if (config.experimentalDefer) {
176+
this.__experimentalDefer = true;
178177
this._directives = [].concat(this._directives, [GraphQLDeferDirective]);
179-
} else {
180-
this.____experimentalDefer = false;
181178
}
182179

183180
if (config.experimentalStream) {
184181
this.__experimentalStream = true;
185182
this._directives = [].concat(this._directives, [GraphQLStreamDirective]);
186-
} else {
187-
this.__experimentalStream = false;
188183
}
189184

190185
// Build type map now to detect any errors within this schema.

0 commit comments

Comments
 (0)