Anders Kindberg
Aug 23 · 1 min read

As part of our work to migrate our main website to a GraphQL back-end we created some code that we felt that others could find useful too.

We wanted to run few GraphQL queries, but at the same time want every (React) component on the page to be able to specify its own data needs. We knew Relay does something like this, but we’re not using Relay. Thus we came up with createFragment(), where components specify the fields they use, and createQuery(), where a top-level component can easily combine those fragments into a valid query.

Those functions are now packaged into the graphql-defragmentizer library, which we just released as Open Source. The code, with examples, can be found at https://github.com/SVT/graphql-defragmentizer.

It’s under the MIT license, so feel free to contribute!

The SVT Tech Blog

SVT is Swedens public service broadcaster. At SVT interactive, SVTi, we develop SVT:s digital products. This is where you get to know what’s going on in our teams.

Anders Kindberg

Written by

The SVT Tech Blog

SVT is Swedens public service broadcaster. At SVT interactive, SVTi, we develop SVT:s digital products. This is where you get to know what’s going on in our teams.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade