Skip to content

Announcing contributed custom scalar specs at scalars.graphql.org #1353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/content/blog/2023-01-14-graphql-scalars.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: GraphQL Custom Scalar specifications
tags: ["announcements"]
layout: blog
date: 2023-01-14
byline: Andreas Marek, Donna Zhou
permalink: /blog/2023-01-14-graphql-scalars
---

# Announcing contributed GraphQL custom scalar specifications

We are very happy to announce the official home for contributed GraphQL [custom scalar](https://spec.graphql.org/draft/#sec-Scalars.Custom-Scalars) specifications at [scalars.graphql.org](https://scalars.graphql.org/).

You are welcome to contribute custom scalar specifications (abbreviated as "specs"). Once your spec is merged in, it will be hosted at `scalars.graphql.org/<GitHub-username>/<specification-name>`. See how to contribute on the [contribution guide](https://scalars.graphql.org/readme-contribution-guide).

Our first contributed spec is for [DateTime](https://scalars.graphql.org/andimarek/date-time). You can point users to the spec's URL with the built-in `@specifiedBy` [directive](https://spec.graphql.org/draft/#sec--specifiedBy) in your GraphQL schema.

```graphql
scalar DateTime
@specifiedBy(url: "https://scalars.graphql.org/andimarek/date-time")
```

## Elevating the GraphQL type system with custom scalars

Custom scalars have been part of the GraphQL spec since day one. They have the unique ability to extend the GraphQL type system with custom types. While custom scalars are powerful, they were more like a black box for the consumers of the API.

Originally, it was very hard for consumers to understand custom scalars as a GraphQL schema did not provide any information apart from its name. For example, it was difficult to understand the exact format of a `DateTime` custom scalar. It was also difficult to know whether the `DateTime` custom scalar in API A was exactly the same as the `DateTime` in API B.

We added the built-in `@specifiedBy` directive some time ago, which assigns a URL for the spec of a custom scalar. This provides a standard way to document custom scalars. The `@specifiedBy` directive is also introspectable.

However, we have since learned that this was not enough. The burden of writing a custom scalar specs and hosting them was left for each API itself to solve.

With the custom scalar spec project, we provide templates for writing custom scalar specs and also host the specs at a GraphQL Foundation owned domain [scalars.graphql.org](https://scalars.graphql.org/). This greatly reduces the effort to clearly document and share your custom scalar specs.

Our hope is that this enables an ecosystem of clearly documented custom scalars and eliminates the need to reinvent popular ones again and again. Ultimately, a popular enough custom scalar will be practically indistinguishable from the built-in ones and elevate the GraphQL type system.

## Get involved!

See how to contribute a custom scalar spec on the [contribution guide](https://scalars.graphql.org/readme-contribution-guide).

If you have any comments or questions, please open an issue on the [graphql-scalars GitHub repository](https://github.com/graphql/graphql-scalars).