GraphQL Library
Contents
GraphQL Library enables Enonic XP applications to define custom GraphQL schemas and execute queries against them.
When to use it
Use this library when an application needs to expose its own GraphQL API, with application-specific types, resolvers, mutations, or subscriptions. It is different from Guillotine, which provides a ready-made GraphQL API for querying CMS content.
How it works
The library builds on XP’s universal API framework. GraphQL Library defines the schema and executes operations against it. A universal API serves that schema over HTTP, deciding where the endpoint is mounted and who is allowed to reach it. Subscriptions use the same framework, streaming their events over SSE or a WebSocket.
Modules
The library provides three server-side JavaScript modules:
-
/lib/graphql -
Defines schemas, types, scalar constants, type wrappers, and query execution.
-
/lib/graphql-connection -
Adds cursor encoding and Relay-style connection types.
-
/lib/graphql-rx -
Provides publishers and subscribers for GraphQL subscriptions.
Compatibility
GraphQL Library 3 requires Enonic XP 8.0 or newer.
For applications running on XP 7, use GraphQL Library 2.x.
Installation
Add the Enonic repository and the library dependency to your application’s build.gradle:
repositories {
mavenLocal()
mavenCentral()
xp.enonicRepo()
}
dependencies {
include 'com.enonic.lib:lib-graphql:3.0.0'
}
Use the latest available 3.x version in place of 3.0.0.
Next steps
Start with the usage guide to create and execute a small schema. See the modules for every exported constant and function, and release notes for version-specific changes.