DEV Community

Stew West
Stew West

Posted on

GraphQL in Twig!

In 2019 I presented "a beginner’s guide on how to use GraphQL in Twig" - to progressively decouple Drupal's Front end at Decoupled Days in New York.

Decoupled Drupal is part of the future, but learning an entirely new stack can be daunting (like React, Vue or Angular, if you haven't used those before).

Writing GraphQL inside Twig templates gives developers a path to an accessible soft-decoupled approach.

This session will introduce GraphQL queries and demonstrate the advantages of changing the Drupal push model to a pull model by letting the template define its data requirements.

Quick Benefits

  • Performance
    -- Everything done in the same GraphQL “request”, no HTTP request is made.
    -- Queries are cached
    -- Queries are grouped within multiple templates
    -- Under the hood, it's like an additional hook

  • Advantages
    -- We still get Drupal forms
    -- We still get translations out of the box
    -- We still get all the nice features as it ...
    -- Works alongside with standard Drupal
    -- We have a common language between Backend and Frontend!
    -- Reduced risk / cost

In the future: it is easier to partly decouple (ie: some React driven components), and it lays a foundation path to fully decouple. “Future proof”.

See the Presentation here.

https://www.youtube.com/watch?v=lknMgevZqu0

Links:

Resources

Sentry image

Make it make sense

Only get the information you need to fix your code that’s broken with Sentry.

Start debugging →

Top comments (0)

Dev Diairies image

User Feedback & The Pivot That Saved The Project

🔥 Check out Episode 3 of Dev Diairies, following a successful Hackathon project turned startup.

Watch full video 🎥

👋 Kindness is contagious

Dive into this thoughtful piece, beloved in the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A sincere "thank you" can brighten someone's day—leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay