You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/schema/directives.md
+11-10Lines changed: 11 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ directive @deprecated(
32
32
) on FIELD_DEFINITION | ENUM_VALUE
33
33
```
34
34
35
-
This indicates that `@deprecated` can decorate either a `SCHEMA_FIELD` definition (as shown at the top of the article) or a schema `ENUM_VALUE` definition (as shown here):
35
+
This indicates that `@deprecated` can decorate either a schema `FIELD_DEFINITION` (as shown at the top of the article) or a schema `ENUM_VALUE` definition (as shown here):
36
36
37
37
```graphql:title=schema.graphql
38
38
enum MyEnum {
@@ -43,7 +43,7 @@ enum MyEnum {
43
43
44
44
If `@deprecated` appears elsewhere in a GraphQL document, it produces an error.
45
45
46
-
> If you [create a custom directive](#creating), you need to define it (and its valid locations) in your schema. You don't need to define [default directives](#default-directives) like `@deprecated`.
46
+
> If you [create a custom directive](#custom-schema-directives), you need to define it (and its valid locations) in your schema. You don't need to define [default directives](#default-directives) like `@deprecated`.
47
47
48
48
### Schema directives vs. operation directives
49
49
@@ -63,25 +63,26 @@ The [GraphQL specification](http://spec.graphql.org/June2018/#sec-Type-System.Di
63
63
|`@skip(if: Boolean!)`| If `true`, the decorated field or fragment in an operation is _not_ resolved by the GraphQL server. |
64
64
|`@include(if: Boolean!)`| If `false`, the decorated field or fragment in an operation is _not_ resolved by the GraphQL server. |
65
65
66
-
## Custom directives
66
+
## Custom schema directives
67
67
68
-
### Creating
68
+
You can extend Apollo Server with custom schema directives created by you or a third party.
69
69
70
-
See [Implementing directives](/schema/creating-directives/).
70
+
> To learn how to create custom directives, see [implementing directives](./creating-directives/).
71
71
72
-
### Using
72
+
To use a custom directive:
73
73
74
-
You can extend Apollo Server with custom schema directives created by you or a third party.
74
+
1. Make sure the directive is defined in your schema with all valid locations listed.
75
+
2. If the directive uses a `SchemaDirectiveVisitor` subclass to perform custom logic, provide it to the `ApolloServer` constructor via the `schemaDirectives` object.
75
76
76
-
To use a custom directive, pass its associated `SchemaDirectiveVisitor` subclass to Apollo Server via the `schemaDirectives`argument. This object maps the name of a directive (e.g., `upper`) to the class that implements its behavior (e.g., `UpperCaseDirective`).
77
+
_The `schemaDirectives` object maps the name of a directive (e.g., `upper`) to the subclass that implements its behavior (e.g., `UpperCaseDirective`)._
77
78
78
-
Also make sure the directive is defined in your schema with all valid locations listed.
79
+
The following example defines an `UpperCaseDirective` subclass for use with the `@upper` custom directive. Because it's decorated with `@upper`, the `Query.hello` field returns `HELLO WORLD!` instead of `Hello world!`.
0 commit comments