Skip to content

Commit 288360b

Browse files
Stephen BarlowStephen Barlow
authored andcommitted
Incorporate more feedback from glasser
1 parent 2e1d666 commit 288360b

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

docs/source/api/apollo-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ The default value is `true`, **unless** the `NODE_ENV` environment variable is s
141141

142142
<td>
143143

144-
A map of all [custom schema directives](../schema/directives/#custom-directives) used in your schema, if any.
144+
A map of all [custom schema directives](../schema/directives/#custom-schema-directives) used in your schema, if any.
145145
</td>
146146
</tr>
147147

docs/source/schema/directives.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ directive @deprecated(
3232
) on FIELD_DEFINITION | ENUM_VALUE
3333
```
3434

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):
3636

3737
```graphql:title=schema.graphql
3838
enum MyEnum {
@@ -43,7 +43,7 @@ enum MyEnum {
4343

4444
If `@deprecated` appears elsewhere in a GraphQL document, it produces an error.
4545

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`.
4747
4848
### Schema directives vs. operation directives
4949

@@ -63,25 +63,26 @@ The [GraphQL specification](http://spec.graphql.org/June2018/#sec-Type-System.Di
6363
| `@skip(if: Boolean!)` | If `true`, the decorated field or fragment in an operation is _not_ resolved by the GraphQL server. |
6464
| `@include(if: Boolean!)` | If `false`, the decorated field or fragment in an operation is _not_ resolved by the GraphQL server. |
6565

66-
## Custom directives
66+
## Custom schema directives
6767

68-
### Creating
68+
You can extend Apollo Server with custom schema directives created by you or a third party.
6969

70-
See [Implementing directives](/schema/creating-directives/).
70+
> To learn how to create custom directives, see [implementing directives](./creating-directives/).
7171
72-
### Using
72+
To use a custom directive:
7373

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.
7576

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`)._
7778

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!`.
7980

8081
```js{20,40-42}
8182
const { ApolloServer, gql, SchemaDirectiveVisitor } = require('apollo-server');
8283
const { defaultFieldResolver } = require('graphql');
8384
84-
// Class definition for an @upper directive
85+
// Subclass definition for @upper directive logic
8586
class UpperCaseDirective extends SchemaDirectiveVisitor {
8687
visitFieldDefinition(field) {
8788
const { resolve = defaultFieldResolver } = field;

0 commit comments

Comments
 (0)