-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add missing directive definitions #3656
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,16 +31,25 @@ | |
| @PublicApi | ||
| public class Directives { | ||
|
|
||
| private static final String SPECIFIED_BY = "specifiedBy"; | ||
| private static final String DEPRECATED = "deprecated"; | ||
| private static final String INCLUDE = "include"; | ||
| private static final String SKIP = "skip"; | ||
| private static final String SPECIFIED_BY = "specifiedBy"; | ||
| private static final String ONE_OF = "oneOf"; | ||
| private static final String DEFER = "defer"; | ||
|
|
||
| public static final String NO_LONGER_SUPPORTED = "No longer supported"; | ||
| public static final DirectiveDefinition DEPRECATED_DIRECTIVE_DEFINITION; | ||
| public static final DirectiveDefinition INCLUDE_DIRECTIVE_DEFINITION; | ||
| public static final DirectiveDefinition SKIP_DIRECTIVE_DEFINITION; | ||
| public static final DirectiveDefinition SPECIFIED_BY_DIRECTIVE_DEFINITION; | ||
| @ExperimentalApi | ||
| public static final DirectiveDefinition ONE_OF_DIRECTIVE_DEFINITION; | ||
| @ExperimentalApi | ||
| public static final DirectiveDefinition DEFER_DIRECTIVE_DEFINITION; | ||
|
|
||
| public static final String BOOLEAN = "Boolean"; | ||
| public static final String STRING = "String"; | ||
| public static final String NO_LONGER_SUPPORTED = "No longer supported"; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In more recent code, as a general rule we prefer to not have random strings hanging about. Some parts of this class haven't been changed in a long while and still have strings. If you prefer I can give the |
||
|
|
||
| static { | ||
| DEPRECATED_DIRECTIVE_DEFINITION = DirectiveDefinition.newDirectiveDefinition() | ||
|
|
@@ -54,11 +63,39 @@ public class Directives { | |
| newInputValueDefinition() | ||
| .name("reason") | ||
| .description(createDescription("The reason for the deprecation")) | ||
| .type(newTypeName().name("String").build()) | ||
| .type(newTypeName().name(STRING).build()) | ||
| .defaultValue(StringValue.newStringValue().value(NO_LONGER_SUPPORTED).build()) | ||
| .build()) | ||
| .build(); | ||
|
|
||
| INCLUDE_DIRECTIVE_DEFINITION = DirectiveDefinition.newDirectiveDefinition() | ||
| .name(INCLUDE) | ||
| .directiveLocation(newDirectiveLocation().name(FRAGMENT_SPREAD.name()).build()) | ||
| .directiveLocation(newDirectiveLocation().name(INLINE_FRAGMENT.name()).build()) | ||
| .directiveLocation(newDirectiveLocation().name(FIELD.name()).build()) | ||
| .description(createDescription("Directs the executor to include this field or fragment only when the `if` argument is true")) | ||
| .inputValueDefinition( | ||
| newInputValueDefinition() | ||
| .name("if") | ||
| .description(createDescription("Included when true.")) | ||
| .type(newNonNullType(newTypeName().name(BOOLEAN).build()).build()) | ||
| .build()) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A comment for myself: in AST land, |
||
| .build(); | ||
|
|
||
| SKIP_DIRECTIVE_DEFINITION = DirectiveDefinition.newDirectiveDefinition() | ||
| .name(SKIP) | ||
| .directiveLocation(newDirectiveLocation().name(FRAGMENT_SPREAD.name()).build()) | ||
| .directiveLocation(newDirectiveLocation().name(INLINE_FRAGMENT.name()).build()) | ||
| .directiveLocation(newDirectiveLocation().name(FIELD.name()).build()) | ||
| .description(createDescription("Directs the executor to skip this field or fragment when the `if` argument is true.")) | ||
| .inputValueDefinition( | ||
| newInputValueDefinition() | ||
| .name("if") | ||
| .description(createDescription("Skipped when true.")) | ||
| .type(newNonNullType(newTypeName().name(BOOLEAN).build()).build()) | ||
| .build()) | ||
| .build(); | ||
|
|
||
| SPECIFIED_BY_DIRECTIVE_DEFINITION = DirectiveDefinition.newDirectiveDefinition() | ||
| .name(SPECIFIED_BY) | ||
| .directiveLocation(newDirectiveLocation().name(SCALAR.name()).build()) | ||
|
|
@@ -67,7 +104,7 @@ public class Directives { | |
| newInputValueDefinition() | ||
| .name("url") | ||
| .description(createDescription("The URL that specifies the behaviour of this scalar.")) | ||
| .type(newNonNullType(newTypeName().name("String").build()).build()) | ||
| .type(newNonNullType(newTypeName().name(STRING).build()).build()) | ||
| .build()) | ||
| .build(); | ||
|
|
||
|
|
@@ -76,6 +113,26 @@ public class Directives { | |
| .directiveLocation(newDirectiveLocation().name(INPUT_OBJECT.name()).build()) | ||
| .description(createDescription("Indicates an Input Object is a OneOf Input Object.")) | ||
| .build(); | ||
|
|
||
| DEFER_DIRECTIVE_DEFINITION = DirectiveDefinition.newDirectiveDefinition() | ||
| .name(DEFER) | ||
| .directiveLocation(newDirectiveLocation().name(FRAGMENT_SPREAD.name()).build()) | ||
| .directiveLocation(newDirectiveLocation().name(INLINE_FRAGMENT.name()).build()) | ||
| .description(createDescription("This directive allows results to be deferred during execution")) | ||
| .inputValueDefinition( | ||
| newInputValueDefinition() | ||
| .name("if") | ||
| .description(createDescription("Deferred behaviour is controlled by this argument")) | ||
| .type(newNonNullType(newTypeName().name(BOOLEAN).build()).build()) | ||
| .defaultValue(BooleanValue.newBooleanValue(true).build()) | ||
| .build()) | ||
| .inputValueDefinition( | ||
| newInputValueDefinition() | ||
| .name("label") | ||
| .description(createDescription("A unique label that represents the fragment being deferred")) | ||
| .type(newTypeName().name(STRING).build()) | ||
| .build()) | ||
| .build(); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -104,33 +161,36 @@ public class Directives { | |
| .type(GraphQLString) | ||
| .description("A unique label that represents the fragment being deferred") | ||
| ) | ||
| .definition(DEFER_DIRECTIVE_DEFINITION) | ||
| .build(); | ||
|
|
||
| public static final GraphQLDirective IncludeDirective = GraphQLDirective.newDirective() | ||
| .name("include") | ||
| .name(INCLUDE) | ||
| .description("Directs the executor to include this field or fragment only when the `if` argument is true") | ||
| .argument(newArgument() | ||
| .name("if") | ||
| .type(nonNull(GraphQLBoolean)) | ||
| .description("Included when true.")) | ||
| .validLocations(FRAGMENT_SPREAD, INLINE_FRAGMENT, FIELD) | ||
| .definition(INCLUDE_DIRECTIVE_DEFINITION) | ||
| .build(); | ||
|
|
||
| public static final GraphQLDirective SkipDirective = GraphQLDirective.newDirective() | ||
| .name("skip") | ||
| .name(SKIP) | ||
| .description("Directs the executor to skip this field or fragment when the `if` argument is true.") | ||
| .argument(newArgument() | ||
| .name("if") | ||
| .type(nonNull(GraphQLBoolean)) | ||
| .description("Skipped when true.")) | ||
| .validLocations(FRAGMENT_SPREAD, INLINE_FRAGMENT, FIELD) | ||
| .definition(SKIP_DIRECTIVE_DEFINITION) | ||
| .build(); | ||
|
|
||
|
|
||
| /** | ||
| * The "deprecated" directive is special and is always available in a graphql schema | ||
| * <p> | ||
| * See https://graphql.github.io/graphql-spec/June2018/#sec--deprecated | ||
| * See <a href="https://spec.graphql.org/draft/#sec--deprecated">the GraphQL specification for @deprecated</a> | ||
| */ | ||
| public static final GraphQLDirective DeprecatedDirective = GraphQLDirective.newDirective() | ||
| .name(DEPRECATED) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andimarek it is declared here, did you also want the annotation to appear elsewhere?
Elsewhere all the defer codepaths have been annotated with
@ExperimentalApiThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect, didn't see that