StepZen is now part of IBM. For the most recent product information and updates visit our
IBM product page.

GraphQL Directives Reference

Core information you need to write your SDL code and leverage GraphQL directives

A schema is defined in a GraphQL Schema Definition Language (SDL) file. It defines your GraphQL API and can incorporate directives - annotations that control how your schema is built and executed.


A directive is an identifier preceded by the @ character, optionally followed by a list of named arguments, which can appear after almost any form of syntax in the GraphQL query or schema languages. (To learn about directives, see the GraphQL draft specification.)


Whether you specify your backends with the stepzen import CLI and let StepZen introspect the backend and generate your schema, or write your own schema code, or a combination of the two, you can take advantage of GraphQL directives that allow you to declaratively connect backends, assemble multiple schemas into one, write a set of queries in sequence, and more.

Specify schemas to include in your project using @sdl

Place one or more schema files (xxxx.graphql) in a directory in your StepZen project.

Create an index.graphql file in the root of that directory, with the following structure. It specifies the relative paths for all the .graphql files you want to assemble into a unified GraphQL schema.

    schema @sdl(
      files: [
         # relative path to each file you want included
      ]
    ) {
        query: Query
    }

Here is an example of an index.graphql file that specifies two schemas:

schema @sdl(files: ["social.graphql", "weather.graphql"]) {
    query: Query
}

Directives

The @sdl directive above is one of several constructs that help build your schema and control how it is executed at run time. See Directives Reference for more.