Due to their unrestricted nature, directives are one of GraphQL's more powerful features, enabling GraphQL servers to provide custom capabilities

Exploring GraphQL Directives in the Wild

submited by
Style Pass
2021-06-04 23:00:08

Due to their unrestricted nature, directives are one of GraphQL's more powerful features, enabling GraphQL servers to provide custom capabilities not supported by the GraphQL spec, and offering a glimpse of what GraphQL may look like in the future.

Directives are suitable for those generic functionalities that can be applied across several parts of the application, such as:

Some time ago, I wrote article GraphQL directives are underrated, expressing how we can benefit from directives. In this write-up I expand on the topic, attempting to find out what actual directives are out there, available to our use.

I will do a discovery tour of directives in the wild, as offered by different GraphQL servers, tools and services, and including both schema-type directives (used to help build the GraphQL schema) and query-type directives (used to alter the response when resolving the query).

@specifiedBy has been added to the spec very recently, so not all GraphQL servers support it yet. It is used to provide a specification URL for declaring how custom scalar types behave.

Leave a Comment