As part of my work on Contentacms I played a bit around with graphql for Drupal.

Here is a short experience report of the first steps.

Installation

The module was easy to install:

composer require drupal/graphql

Once this was done, modules/graphql and especially modules/graphql/modules was filled.

Usage

Reading the readme, which points to another readme, it was clear which modules are needed:

  • graphql_core
  • graphql_content
  • graphql_entity_reference
  • graphql_file
  • graphql_image

Experiments

Disclaimer: I would have known how to use graphql, but I try to play the ignorant person here …

I heard the module comes with an explorer on /graphql/explorer, so here is a first impression.

I wrote {} and pressed tab in the middle:

Graphql autocompletion

Its hard to deny, this is a REALLY nice experience.

As next step my goal was to select a single node. The former autocompletion has nodeById, so let’s type that and see again. It asked me to provide an id and a language and wow, here is the data:

Graphql autocompletion nodeById

As last step for this blogpost I try to get more fields from recipes …

Clicking throught the repo I found https://github.com/fubhy/graphql-drupal/blob/8.x-3.x/modules/graphql_content/tests/queries/rendered_fields.gql and the syntax ... on NodeTest {, so let’s use that:

Graphql autocompletion ... on NodeRecipe

Summary

Is Graphql in Drupal ready to be used? I can’t say that, but it is in a better state than it ever was. Fubhy and others have made good progress!

I’m looking forward to write more blog posts about my experiments.