From 26c6b2c4b99c5f887414f0b6132be139e35badf4 Mon Sep 17 00:00:00 2001 From: Shane Myrick Date: Tue, 5 Mar 2024 10:50:41 -0800 Subject: [PATCH] [docs] Update custom-scalars with specified by (#7831) Add links to the `@specifiedBy` directive --- docs/source/schema/custom-scalars.mdx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/source/schema/custom-scalars.mdx b/docs/source/schema/custom-scalars.mdx index fede86a4994..85d228035e8 100644 --- a/docs/source/schema/custom-scalars.mdx +++ b/docs/source/schema/custom-scalars.mdx @@ -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