Selecting your endpoint

As a first step you need to select the Endpoint that you want to use for the queries. The endpoint is appropriate to the Sites configuration that you want to use for your queries.

This is available from the drop-down list at the top-right.

Creating, and persisting, a new query

You can enter your new query in the editor - which is in the middle-left panel, directly under the GraphiQL logo.

NOTE
If you have a persisted query already selected, and showing in the editor panel, then select + (next to Persisted Queries) to empty the editor ready for your new query.

Just start typing, the editor also:

  • uses mouse-over to show you additional information about elements
  • provides features such as syntax-highlighting, auto-complete, auto-suggest
NOTE
GraphQL queries typically start with a { character.
Lines that start with a # are ignored.

Use Save As to persist your new query.

Updating your persisted query

Select the query you want to update from the list in the Persisted Queries panel (far left).

The query is shown in the editor panel. Make any changes you need, then use Save to commit your updates to the persisted query.

Running queries

You can run a new query immediately, or you can load and run a persisted query. To load a persisted query, select it from the list - the query is shown in the editor panel.

In either case, the query showing in the editor panel is the query that will be executed when you either:

  • click on the Execute Query icon
  • use the keyboard combination Control-Enter

Query variables

The GraphiQL IDE also lets you manage your Query Variables.

For example:

GraphQL Variables

Publishing persisted queries

Once you have selected your persisted query from the list (left panel) you can use the Publish and Unpublish actions. This will activate them to your publish environment (for example, dev-publish) for easy access by your applications when testing.

NOTE
The definition of the persisted query’s cache Time To Live {“cache-control”:“parameter”:value} has a default value of 2 hours (7200 seconds).

Copy URL to directly access the query

The Copy URL option lets you simulate a query, by copying the URL used to directly access the persisted query and see the results. This can then be used for testing; for example, by accessing in a browser:

For example:

http://localhost:4502/graphql/execute.json/global/article-list-01

By using this URL in a browser, you can confirm the results:

GraphiQL - Copy URL

The Copy URL option is accessible via the three vertical dots to the right of the persisted query name (far left panel):

GraphiQL - Copy URL

Deleting persisted queries

The Delete option is also accessible via the three vertical dots to the right of the persisted query name (far left panel).

Installing your Persisted Query on Production

After developing and testing your persisted query with GraphiQL, the final goal is to transfer it to your production environment for use by your applications.

Keyboard shortcuts

There are a selection of keyboard shortcuts that provide direct access to action icons in the IDE:

  • Prettify Query: Shift-Control-P
  • Merge Query: Shift-Control-M
  • Execute Query: Control-Enter
  • Auto Complete: Control-Space
NOTE
On some keyboards the Control key is labelled as Ctrl.

Experience Manager


Connect with Experience League at Summit!

Get front-row access to top sessions, hands-on activities, and networking—wherever you are!

Learn more