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

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️