How do I create custom directives in Apollo Server v4?

From Apollo Server v1 to v3, there is a page of Custom Directives in the documentations.

I noticed that in v4 this page is missing, is there a new way of creating custom directive and it’s corresponding resolves in v4?

Hello @vicary!

I work on the docs here at Apollo; thank you for this question! In Apollo Server 4, we removed the “Creating schema directives” article because Apollo Server itself doesn’t have built-in support for custom directives. Instead, we recommend folks use the @graphql-tools package and reference their documentation for the most up-to-date info on how to implement custom directives.

We do have an example of creating a custom directive with Apollo Server 4, but I just realized I forgot to plug this example in AS4’s Directives article. I’ll do that now, and thank you so much for helping to improve our documentation!


  • Rose

And just to be a bit more explicit: we removed the built-in support for custom directives in AS3. We left around a documentation page that essentially just told how to use graphql-tools during AS3, but at some point it doesn’t make sense for us to maintain documentation for third-party projects in our docs site. The AS3 docs should still generally work though (once you fix the import path for ApolloServer itself).

1 Like