GraphQL Fragments shared between resources

Hello,

We heavily use GraphQL with Retool and I am hoping to see a feature of GraphQL utilized in Retool. This feature is the use of Fragments. For clarification, a fragment can be defined as:

A GraphQL fragment is a piece of logic that can be shared between multiple queries and mutations .

Some of our larger Retool apps may have 15 or more GraphQL queries and mutations. Often these queries have a shared set of fields which are returned from them. On multiple occasions I've noticed that a field may be missing from one or more queries or mutations causing an error or missing data. If a shared fragment could be defined, that fragment could be used between the different queries and mutations. I guess it would have to be it's own GraphQL resource type and referenced by other GraphQL resource types.

Honestly as I thought about that I almost deleted this post, but decided to keep it just in case someone else thinks could be useful and could think through an implementation of it. I guess things get complicated on the Retool side referencing the other resources, and probably the need for more than one resource (it's not uncommon to reference many fragments in a large query).

The way this is managed now is copy and pasting between all the different queries to ensure the same set of fields are being referenced between them.

1 Like

+1 We would also benefit from the ability to share fragments across queries and mutations.

Thanks, @kexline4710 ! I've added your +1 interest to our internal feature request for the eng team on this. We're still gathering feedback and +1s here and it's not currently on the roadmap, so if others would also like to see this implemented, please let us know. Thanks!

Hi there,

any update on that feature?

1 Like

hey @lyrold no new updates at the moment -- it's still not planned on the roadmap, but I'll pass new interest along internally (just did so given your interest!) :slightly_smiling_face: