Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
In this case, @rest is a custom directive that can be applied to a query. In the above example, we've supplied only one argument to the directive (endpoint). StepZen uses this directive to write the resolver that handles the getArticles query so that it can connect this query to data from the supplied REST endpoint. StepZen has a similar directive, @dbquery, for connecting a database backend. There are also community implementations of a similar @rest directive.
GraphQL directives are an incredibly powerful aspect of the GraphQL specification, but you may not be aware of them or have had the opportunity to ever use them. This is partly because the GraphQL spec only defines two "required" directives for an API to be spec compliant, and, even then, they aren't necessarily ones you'd encounter on a regular basis. However, GraphQL directives provide extensibility to to a GraphQL API and server in a way that makes them incredibly important, especially to tools like StepZen. In this post, we'll look at what GraphQL directives are, how they are used and some examples of directives in use.