Skip to content

Commit 097e7d7

Browse files
lilianammmatosrobrichard
authored andcommitted
Add @defer directive to schema
1 parent 58c72ab commit 097e7d7

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export {
6262
specifiedDirectives,
6363
GraphQLIncludeDirective,
6464
GraphQLSkipDirective,
65+
GraphQLDeferDirective,
6566
GraphQLDeprecatedDirective,
6667
GraphQLSpecifiedByDirective,
6768
// "Enum" of Type Kinds

src/type/directives.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,29 @@ export const GraphQLSkipDirective: GraphQLDirective = new GraphQLDirective({
165165
},
166166
});
167167

168+
/**
169+
* Used to conditionally defer fragments.
170+
*/
171+
export const GraphQLDeferDirective = new GraphQLDirective({
172+
name: 'defer',
173+
description:
174+
'Directs the executor to defer this fragment when the `if` argument is true or undefined.',
175+
locations: [
176+
DirectiveLocation.FRAGMENT_SPREAD,
177+
DirectiveLocation.INLINE_FRAGMENT,
178+
],
179+
args: {
180+
if: {
181+
type: GraphQLBoolean,
182+
description: 'Deferred when true or undefined.',
183+
},
184+
label: {
185+
type: GraphQLString,
186+
description: 'Unique name',
187+
},
188+
},
189+
});
190+
168191
/**
169192
* Constant string used for default reason for a deprecation.
170193
*/

src/type/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export {
133133
specifiedDirectives,
134134
GraphQLIncludeDirective,
135135
GraphQLSkipDirective,
136+
GraphQLDeferDirective,
136137
GraphQLDeprecatedDirective,
137138
GraphQLSpecifiedByDirective,
138139
// Constant Deprecation Reason

0 commit comments

Comments
 (0)