Skip to content

Commit 1ae79cb

Browse files
committed
Add @stream directive to schema
1 parent df01dec commit 1ae79cb

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export {
6363
GraphQLIncludeDirective,
6464
GraphQLSkipDirective,
6565
GraphQLDeferDirective,
66+
GraphQLStreamDirective,
6667
GraphQLDeprecatedDirective,
6768
GraphQLSpecifiedByDirective,
6869
// "Enum" of Type Kinds

src/type/directives.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
defineArguments,
1919
GraphQLNonNull,
2020
} from './definition';
21-
import { GraphQLBoolean, GraphQLString } from './scalars';
21+
import { GraphQLBoolean, GraphQLInt, GraphQLString } from './scalars';
2222

2323
/**
2424
* Test if the given value is a GraphQL directive.
@@ -188,6 +188,31 @@ export const GraphQLDeferDirective = new GraphQLDirective({
188188
},
189189
});
190190

191+
/**
192+
* Used to conditionally stream list fields.
193+
*/
194+
export const GraphQLStreamDirective = new GraphQLDirective({
195+
name: 'stream',
196+
description:
197+
'Directs the executor to stream plural fields when the `if` argument is true or undefined.',
198+
locations: [DirectiveLocation.FIELD],
199+
args: {
200+
if: {
201+
type: GraphQLBoolean,
202+
description: 'Stream when true or undefined.',
203+
},
204+
label: {
205+
type: GraphQLString,
206+
description: 'Unique name',
207+
},
208+
initialCount: {
209+
defaultValue: 0,
210+
type: GraphQLInt,
211+
description: 'Number of items to return immediately',
212+
},
213+
},
214+
});
215+
191216
/**
192217
* Constant string used for default reason for a deprecation.
193218
*/

src/type/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export {
132132
GraphQLIncludeDirective,
133133
GraphQLSkipDirective,
134134
GraphQLDeferDirective,
135+
GraphQLStreamDirective,
135136
GraphQLDeprecatedDirective,
136137
GraphQLSpecifiedByDirective,
137138
// Constant Deprecation Reason

0 commit comments

Comments
 (0)