Skip to content

Add support for defer and stream directives (Feedback is welcome) #2839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add @defer directive to schema
  • Loading branch information
lilianammmatos authored and robrichard committed Jun 23, 2022
commit b371e5335aa579212583476b6533fa09292cd4c3
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export {
specifiedDirectives,
GraphQLIncludeDirective,
GraphQLSkipDirective,
GraphQLDeferDirective,
GraphQLDeprecatedDirective,
GraphQLSpecifiedByDirective,
// "Enum" of Type Kinds
Expand Down
23 changes: 23 additions & 0 deletions src/type/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,29 @@ export const GraphQLSkipDirective: GraphQLDirective = new GraphQLDirective({
},
});

/**
* Used to conditionally defer fragments.
*/
export const GraphQLDeferDirective = new GraphQLDirective({
name: 'defer',
description:
'Directs the executor to defer this fragment when the `if` argument is true or undefined.',
locations: [
DirectiveLocation.FRAGMENT_SPREAD,
DirectiveLocation.INLINE_FRAGMENT,
],
args: {
if: {
type: GraphQLBoolean,
description: 'Deferred when true or undefined.',
},
label: {
type: GraphQLString,
description: 'Unique name',
},
},
});

/**
* Constant string used for default reason for a deprecation.
*/
Expand Down
1 change: 1 addition & 0 deletions src/type/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export {
specifiedDirectives,
GraphQLIncludeDirective,
GraphQLSkipDirective,
GraphQLDeferDirective,
GraphQLDeprecatedDirective,
GraphQLSpecifiedByDirective,
// Constant Deprecation Reason
Expand Down