An implementation of the standard GraphiQL IDE is available for use with the GraphQL API of Adobe Experience Manager (AEM).
GraphiQL is included in all environments of AEM (but will only be accessible/visible when you configure your endpoints).
In previous releases, a package was needed to install the GraphiQL IDE. If you have this installed, it can now be removed.
You must have configured your endpoints in the configuration browser before using the GraphiQL IDE.
The GraphiQL tool allows you to test and debug your GraphQL queries by enabling you to:
dev-publish
)You can access the query editor from either:
http://localhost:4502/aem/graphiql.html
You can use GraphiQL on your system so that queries can be requested by your client application using GET requests, and for publishing queries. For production usage, you can then move your queries to your production environment. Initially to production author for validating newly authored content with the queries, and finally production publish for live consumption.
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.
You can enter your new query in the editor - which is in the middle-left panel, directly under the GraphiQL logo.
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:
GraphQL queries typically start with a {
character.
Lines that start with a #
are ignored.
Use Save As to persist your new query.
Select the query you want to update from the list in the Persisted Queries panel (far left).
The query will be shown in the editor panel. Make any changes you need, then use Save to commit your updates to the persisted query.
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 will be 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:
Control-Enter
The GraphiQL IDE also allows you to manage your Query Variables.
For example:
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.
The definition of the persisted query’s cache Time To Live
{“cache-control”:“parameter”:value} has a default value of 2 hours (7200 seconds).
The Copy URL option allows you to 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:
The Copy URL option is accessible via the three vertical dots to the right of the persisted query name (far left panel):
The Delete option is also accessible via the three vertical dots to the right of the persisted query name (far left panel).
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.
There are a selection of keyboard shortcuts that provide direct access to action icons in the IDE:
Shift-Control-P
Shift-Control-M
Control-Enter
Control-Space
On some keyboards the Control
key is labelled as Ctrl
.