Fluent Commerce Logo
Docs

Example of how to use Fragment in GQL within Fluent. We will be using fulfilments

How-to Guide

Author:

Fluent Commerce

Changed on:

13 Dec 2023

Key Points

  • Example on how to use fragments in GQL

Steps

Step arrow right iconHere is the standard query GQL to get the fulfilment data:

Here is the standard query GQL to get the fulfilment data:No alt provided

Step arrow right iconreturning result

No alt provided

Step arrow right iconcreate fragment for the order

Let's say I want to create a new Fragment for “order",  you can create a new fragment at the bottom of the payload and replace the "order" (and the children fields) with ... new fragment name


No alt provided

Step arrow right iconGQL with fragment returning result

No alt provided
As you can see from the result, the order fields are now replaced with "fromFragment". this is showing that the data is now coming from the fragment 

Step arrow right iconNested Fragments

We can even have fragments in the fragment. For example, create a new fragment on order Items:No alt provided

Step arrow right iconnested Fragment result



No alt provided
Fluent Commerce

Fluent Commerce