Drupal and GraphQL
GraphQL, a query language created by Facebook for describing data requirements on complex application data models. Decoupling your content management system enables front-end developers to fully control an application or site's rendered markup and user experience. Furthermore, the use of client-side frameworks helps developers give websites application-like behavior with smoother interactivity (there is never a need to hit refresh, because new data appears automatically), optimistic feedback (a response appears before the server has processed a user's query), and non-blocking user interfaces (the user can continue to interact with the application while portions are still loading).
One of the most difficult issues facing front-end developers is network performance with REST.
Currently, the only way to solve this problem is to create custom API endpoints (e.g. in Views) that comprehensively provide all the data needed by the client in a single response to minimize round trips. However, managing endpoints for each respective client can quickly spiral out of control given the range of different information each client might demand and number of deployed versions in the wild. On the other hand, if you are relying on a single endpoint, updating it requires modifying all the JavaScript that relies on that endpoint and ingests its response. These endpoint management issues can force the front-end developer to depend on work the back-end developer must complete, which creates bottlenecks in decoupled teams.
Decoupling thus reveals the need to investigate better ways of exposing data to the client side. As our pages and applications become ever more component-driven, the complexity of the queries we must perform and our demands on their performance increase. What if we could extract only the data we need by writing queries that are efficient and performant by default? Sebastian Siemssen proposes using Facebook's GraphQL (see demo video and project on drupal.org) due to the client's explicit definition of what schema to return and the use of consolidated queries which break apart into smaller calls and recombine for the response, thereby minimizing round trips.
It means that decoupled sites will enjoy better overall performance and give front-end developers a better experience: very few round trips to the server, no need for custom endpoints, no need for versioning, and no dependence on back-end developers.
Layout management, security, and content previews are unaffected, and within page components, front-end application logic can work its magic.
Disadvantage : Projects and the architecture can get messy, fast and confusing for developers that come on/off the project; necessitating a need for a strong governance model and a well thought out and communicated architecture for how to deal with the decoupled nature of the project.
What we will discuss?
-
What is GraphQL?
-
Why to use GraphQL?
-
How GraphQL works?
-
Drupal Application - Real world scenarios
-
Creating contributed module for this?
-
Detailed Demo to show how Drupal can interact with GraphQL and its benefits to the site