Skip to content

Commit fb2d43c

Browse files
authored
Update Apollo Kotlin specific directives to the latest version (#636)
* Update Apollo Kotlin specific directives to the latest version * Add @defer definition
1 parent 06c4efa commit fb2d43c

File tree

1 file changed

+89
-20
lines changed

1 file changed

+89
-20
lines changed
Lines changed: 89 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,96 @@
1-
# Marks a field or variable definition as optional or required
2-
# By default Apollo Kotlin generates all variables of nullable types as optional, in compliance with the GraphQL specification,
3-
# but this can be configured with this directive, because if the variable was added in the first place, it's usually to pass a value
1+
# Taken from https://specs.apollo.dev/kotlin_labs/v0.2/kotlin_labs-v0.2.graphql
2+
3+
"""
4+
Marks a field or variable definition as optional or required
5+
By default Apollo Kotlin generates all variables of nullable types as optional, in compliance with the GraphQL specification,
6+
but this can be configured with this directive, because if the variable was added in the first place, it's usually to pass a value
7+
Since: 3.0.0
8+
"""
49
directive @optional(if: Boolean = true) on FIELD | VARIABLE_DEFINITION
510

6-
# Marks a field as non-null. The corresponding Kotlin property will be made non-nullable even if the GraphQL type is nullable.
7-
# When used on an object definition in a schema document, `fields` must be non-empty and contain a selection set of fields that should be non-null
8-
# When used on a field from an executable document, `fields` must always be empty
9-
#
10-
# Setting the directive at the schema level is usually easier as there is little reason that a field would be non-null in one place
11-
# and null in the other
11+
"""
12+
Marks a field as non-null. The corresponding Kotlin property will be made non-nullable even if the GraphQL type is nullable.
13+
When used on an object definition in a schema document, `fields` must be non-empty and contain a selection set of fields that should be non-null
14+
When used on a field from an executable document, `fields` must always be empty
15+
16+
Setting the directive at the schema level is usually easier as there is little reason that a field would be non-null in one place
17+
and null in the other
18+
Since: 3.0.0
19+
"""
1220
directive @nonnull(fields: String! = "") on OBJECT | FIELD
1321

14-
# Marks fields as key fields. Key fields are used to compute the cache key of an object
15-
# `keyFields` should contain a selection set. Composite fields are not supported yet.
16-
directive @typePolicy(keyFields: String!) on OBJECT | INTERFACE | UNION
22+
"""
23+
Attach extra information to a given type
24+
Since: 3.0.0
25+
"""
26+
directive @typePolicy(
27+
"""
28+
a selection set containing fields used to compute the cache key of an object. Order is important.
29+
"""
30+
keyFields: String! = "",
31+
"""
32+
a selection set containing fields that shouldn't create a new cache Record and should be
33+
embedded in their parent instead. Order is unimportant.
34+
"""
35+
embeddedFields: String! = "",
36+
"""
37+
a selection set containing fields that should be treated as Relay Connection fields. Order is unimportant.
38+
Since: 3.4.1
39+
"""
40+
connectionFields: String! = ""
41+
) on OBJECT | INTERFACE | UNION
42+
43+
"""
44+
Attach extra information to a given field
45+
Since: 3.3.0
46+
"""
47+
directive @fieldPolicy(
48+
forField: String!,
49+
"""
50+
a list of arguments used to compute the cache key of the object this field is pointing to.
51+
The list is parsed as a selection set: both spaces and comas are valid separators.
52+
"""
53+
keyArgs: String! = "",
54+
"""
55+
(experimental) a list of arguments that vary when requesting different pages.
56+
These arguments are omitted when computing the cache key of this field.
57+
The list is parsed as a selection set: both spaces and comas are valid separators.
58+
Since: 3.4.1
59+
"""
60+
paginationArgs: String! = ""
61+
) repeatable on OBJECT
62+
63+
"""
64+
Indicates that the given field, argument, input field or enum value requires
65+
giving explicit consent before being used.
66+
Since: 3.3.1
67+
"""
68+
directive @requiresOptIn(feature: String!) repeatable
69+
on FIELD_DEFINITION
70+
| ARGUMENT_DEFINITION
71+
| INPUT_FIELD_DEFINITION
72+
| ENUM_VALUE
73+
74+
"""
75+
Use the specified name in the generated code instead of the GraphQL name.
76+
Use this for instance when the name would clash with a reserved keyword or field in the generated code.
77+
This directive is experimental.
78+
Since: 3.3.1
79+
"""
80+
directive @targetName(name: String!)
81+
on OBJECT
82+
| INTERFACE
83+
| ENUM
84+
| ENUM_VALUE
85+
| UNION
86+
| SCALAR
87+
| INPUT_OBJECT
1788

18-
# Indicates how to compute a key from a field arguments.
19-
# `keyArgs` should contain a selection set. Composite args are not supported yet.
20-
directive @fieldPolicy(forField: String!, keyArgs: String!) repeatable on OBJECT
2189

22-
# Indicates that the given field or enum value is still experimental and might be changed
23-
# in a backward incompatible manner
24-
directive @experimental(
25-
reason: String! = "Experimental"
26-
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE
90+
# @defer is not ratified yet in the GraphQL spec, but supported as an experimental feature in Apollo Kotlin
91+
# Taken from https://github.com/apollographql/apollo-kotlin/blob/05f2a3295517fb7a64c2259c38b453a37f3c4d19/libraries/apollo-ast/src/main/resources/builtins.graphqls#L136
2792

93+
directive @defer(
94+
label: String
95+
if: Boolean! = true
96+
) on FRAGMENT_SPREAD | INLINE_FRAGMENT

0 commit comments

Comments
 (0)