Skip to content

Commit d212612

Browse files
committed
Add @stream directive to schema
1 parent 934cc82 commit d212612

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
@@ -16,7 +16,7 @@ import {
1616
defineArguments,
1717
GraphQLNonNull,
1818
} from './definition';
19-
import { GraphQLBoolean, GraphQLString } from './scalars';
19+
import { GraphQLBoolean, GraphQLInt, GraphQLString } from './scalars';
2020

2121
/**
2222
* Test if the given value is a GraphQL directive.
@@ -176,6 +176,31 @@ export const GraphQLDeferDirective = new GraphQLDirective({
176176
},
177177
});
178178

179+
/**
180+
* Used to conditionally stream list fields.
181+
*/
182+
export const GraphQLStreamDirective = new GraphQLDirective({
183+
name: 'stream',
184+
description:
185+
'Directs the executor to stream plural fields when the `if` argument is true or undefined.',
186+
locations: [DirectiveLocation.FIELD],
187+
args: {
188+
if: {
189+
type: GraphQLBoolean,
190+
description: 'Stream when true or undefined.',
191+
},
192+
label: {
193+
type: GraphQLString,
194+
description: 'Unique name',
195+
},
196+
initialCount: {
197+
defaultValue: 0,
198+
type: GraphQLInt,
199+
description: 'Number of items to return immediately',
200+
},
201+
},
202+
});
203+
179204
/**
180205
* Constant string used for default reason for a deprecation.
181206
*/

src/type/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export {
134134
GraphQLIncludeDirective,
135135
GraphQLSkipDirective,
136136
GraphQLDeferDirective,
137+
GraphQLStreamDirective,
137138
GraphQLDeprecatedDirective,
138139
GraphQLSpecifiedByDirective,
139140
// Constant Deprecation Reason

0 commit comments

Comments
 (0)