Experimental package for GraphQL support
Editors note: This blog post was published in December 2018 and has been updated for accuracy. The Graph QL package is no longer experimental and it is shipped as version 1.0 with eZ Platform v2.5. To learn more read [Sneak Peak] eZ Platform v2.5 tech highlights blog post.
GraphQL, designed by Facebook, is foreseen as one of the key technologies for next year and is becoming a cornerstone of the web. In our domain, Web Content Management, it surely is yet a new major step forward for decoupled or headless CMS. In this video, you will discover how it was implemented for eZ Platform, and how to start using it today.
This query language exposes a schema over HTTP, and allows developers to describe precisely what data they want to get from it. This approach fixed the main drawbacks of REST: under and over fetching of data (at 00:07 in the video). It works extremely well with React, without being limited to it: the query language is extremely simple, and the results are returned as JSON.
Our implementation focuses on YOUR repository by exposing the content types you have modeled. In a unique query, you can easily retrieve the latest blog posts, thumbnails for their images, the author's name and email and the links to the blog posts:
{ content { blogPosts(sortBy: [_dateModified, _desc]) { _url title author { name email } intro { html5 } image { alternativeText variation(identifier: small) { uri } } } } }
The response will only contain the requested data, nothing more, nothing less.
The README file will guide you through the installation process. After installing, remember to generate the schema for your repository by running bin/console ezplatform:graphql:generate-schema, and head over to /graphiql to start exploring your content! If you want to test it without installing it, an online demo is available on eZ Platform Cloud.
We provide this feature today as an experimental package aside of the core platform v2.4 release. For convenience, the package is also activated on the demo distribution but is not yet in the core distribution. Our plan is to ship the package as a core component of eZ with the 2.5 release, scheduled for February 2018. It has so far been tested with eZ Platform 2.3 and 2.4 beta, but may work with earlier versions of eZ Platform 2.x.
The package will soon be migrated to the eZ infrastructure. In the meantime, the github issue tracker describes the planned features, several of which are already available in various branches (relay, mutations…). Feel free to report bugs or features!