This repository was archived by the owner on Feb 27, 2023. It is now read-only.
forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectives.java
More file actions
58 lines (49 loc) · 2.56 KB
/
Directives.java
File metadata and controls
58 lines (49 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package graphql;
import graphql.introspection.Introspection;
import graphql.schema.GraphQLDirective;
import graphql.schema.GraphQLNonNull;
import static graphql.Scalars.GraphQLBoolean;
import static graphql.Scalars.GraphQLString;
import static graphql.introspection.Introspection.DirectiveLocation.FIELD;
import static graphql.introspection.Introspection.DirectiveLocation.FIELD_DEFINITION;
import static graphql.introspection.Introspection.DirectiveLocation.FRAGMENT_SPREAD;
import static graphql.introspection.Introspection.DirectiveLocation.INLINE_FRAGMENT;
import static graphql.schema.GraphQLArgument.newArgument;
/**
* The query directives that are under stood by graphql-java
*/
public class Directives {
public static final GraphQLDirective IncludeDirective = GraphQLDirective.newDirective()
.name("include")
.description("Directs the executor to include this field or fragment only when the `if` argument is true")
.argument(newArgument()
.name("if")
.type(new GraphQLNonNull(GraphQLBoolean))
.description("Included when true."))
.validLocations(FRAGMENT_SPREAD, INLINE_FRAGMENT, FIELD)
.build();
public static final GraphQLDirective SkipDirective = GraphQLDirective.newDirective()
.name("skip")
.description("Directs the executor to skip this field or fragment when the `if`'argument is true.")
.argument(newArgument()
.name("if")
.type(new GraphQLNonNull(GraphQLBoolean))
.description("Skipped when true."))
.validLocations(FRAGMENT_SPREAD, INLINE_FRAGMENT, FIELD)
.build();
public static final GraphQLDirective FetchDirective = GraphQLDirective.newDirective()
.name("fetch")
.description("Directs the SDL type generation to create a data fetcher that uses this `from` argument as the property name")
.argument(newArgument()
.name("from")
.type(new GraphQLNonNull(GraphQLString))
.description("The `name` used to fetch values from the underlying object"))
.validLocations(FIELD_DEFINITION)
.build();
@ExperimentalApi
public static final GraphQLDirective DeferDirective = GraphQLDirective.newDirective()
.name("defer")
.description("This experimental directive allows results to be deferred during execution")
.validLocations(Introspection.DirectiveLocation.FIELD)
.build();
}