The GraphQL module allows you to expose content stored in JCR through GraphQLPOST and GET requests. The module provides a GraphQL API, a binding to Magnolia assets and a seamless integration with content types.
Module structure
artifactID
magnolia-graphql-parent
Parent reactor.
magnolia-graphql-assets
Integrates GraphQL with Magnolia assets.
magnolia-graphql-core
Provides the API.
magnolia-graphql-jcr
Integrates GraphQL with Magnolia content types and JCR.
Installing with Maven
Maven is the easiest way to install the module.
Add the following to your bundle:
The module itself does not require any configuration adjustments. It is ready for use once your Magnolia instance is up and running. Registered GraphQL types can be verified using the Definitions app:
Disabling specific GraphQL types
If you need to disable a GraphQL schema for a content type, you can do so through definition decoration, for example:
By default, the GraphQL servlet is enabled. To disable it, set the /server/filters/servlets/GraphQLServlet@enabled property to false.
Changing endpoint name
By default, all GraphQL requests are mapped to /.graphql. You can change this by modifying the pattern property at /server/filters/servlets/GraphQLServlet/mappings/-.graphql--.
Access control
All requests to the GraphQL servlet pass through a filter chain. Make sure that the instance handling GraphQL requests in a production environment has an appropriate assignment of JCR Access Control Lists (ACLs) and Web Access permissions for the GraphQL endpoint and for the JCR workspaces where GraphQL content is stored. For more information, see the Security app.
GraphiQL servlet
The magnolia-graphql-core module installs GraphiQL, a servlet which you can use to explore the GraphQL API and test your GraphQL requests.
The servlet is exposed in two forms:
As the GraphQL app, available in the Dev group of the App launcher.
The servlet is installed as GraphiQLServlet under /server/filters/servlets/.
Its default configuration can be modified under /modules/graphql-core/config/graphiql/ using the following properties.
Base properties
Property
Description
endpoint
optional, default is /.graphql
GraphQL endpoint servlet mapping.
The value must correspond with the value of the pattern property in the GraphQLServlet mapping at /server/filters/servlets/GraphQLServlet/mappings/-.graphql--@pattern
resource
optional, default is /graphql-core/webresources/graphiql/index.ftl
Path to the GraphiQL FreeMarker file.
If needed, resource may be overridden (hotfixed) in the Resources app, or developers can use a path to an FTL file in their own light module.
CDN-related properties
These properties must be configured under /modules/graphql-core/config/graphiql/cdn/.
Property
Description
enabled
optional, default is false
If true, the React and GraphiQL libraries are served from a Content Delivery Network (CDN). Otherwise, they are served via a resource servlet from static resources in the magnolia-graphql-core light module.