Skip to content

Commit

Permalink
[docs] Update custom-scalars with specified by (#7831)
Browse files Browse the repository at this point in the history
Add links to the `@specifiedBy` directive
  • Loading branch information
smyrick authored Mar 5, 2024
1 parent 7e7b83c commit 26c6b2c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/source/schema/custom-scalars.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ scalar MyCustomScalar

You can now use `MyCustomScalar` in your schema anywhere you can use a default scalar (e.g., as the type of an object field, input type field, or argument).

However, Apollo Server still needs to know how to interact with values of this new scalar type.
### Including scalar specification
Updated in the [October 2021 version of the GraphQL spec](https://spec.graphql.org/October2021/#sec--specifiedBy), you can include a `@specifiedBy` directive as metadata for schema consumers to understand what format the scalar is using. This directive does not provide automatic validation, but can provide useful context for humans reading the schema.

```graphql
scalar MyCustomScalar @specifiedBy(url: "https://specs.example.com/rfc111")
```

However, Apollo Server still needs to know how to interact with and generate values of this new scalar type.

## Defining custom scalar logic

Expand Down

0 comments on commit 26c6b2c

Please sign in to comment.