Tools to help developers building new applications on SilverStripe’s GraphQL API
Tools to help developers building new applications on SilverStripeâs GraphQL API
$ composer require --dev silverstripe/graphql-devtools
This module adds an implementation of graphiql, an in-browser IDE for GraphQL servers. It provides browseable documentation of your schema, as well as autocomplete and syntax-checking of your queries.
In GraphQL 3.x, it can be accessed at
In GraphQL 4.x, it can be accessed at
This is because GraphQL 4 has its own
By default, the tool has the same restrictions as other development tools like
composer require --devby default. In most deployment contexts that'll mean it's not available on environments in "test" or "live" modes
In most installations of SilverStripe, there are at least two GraphQL servers running -- one
for the admin (
admin/graphql) and one for the user space (
/graphql). By default, only
default schema will show, but this is configurable.
Important: Due to a limitation in the GraphQL Playground library, showing multiple schemas
will disable the persistence of IDE state across page refreshes.
Also important: When changing the available schemas, be sure to clear the local storage in your browser, otherwise, you'll get inconsistent state.
You can configure the visible schemas in the controller.
Show a select list of schemas
SilverStripe\GraphQLDevTools\Controller: # show two schemas schemas: - default - admin # default schema that is selected default_schema: admin
Show all schemas
SilverStripe\GraphQLDevTools\Controller: # show two schemas schemas: '*' default_schema: default
Further, you can override the config in the request, by using
The IDE finds schemas by checking
Director for routes that map to a
If for some reason you're using a custom controller, you might get an error: "Could not find your default schema 'default'. You will need to add one to the SilverStripe\Control\Director.rules config setting."
To avoid this, you can explicitly map your graphql route to a schema in your Director config:
SilverStripe\Control\Director: rules: graphql: Controller: '%$MyCustomController' Schema: default
The library running the IDE is GraphQL Playground.
It is served from your local environment as an exposed resource. The
setup is based on their "HTML Page" example seen here, which uses remote bundle files served from a CDN. This repository
uses a manually created bundle file copied directly from the CDN.
This may seem like a convoluted approach, but the main benefits are:
To upgrade GraphQL Playground, refer to the example linked above and use their
CDN to download the latest distribution and drop it into this repository. Be sure
to update the comment at the top of the
bundle.js file to track the URL it was
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem