Example of how to use Fragment in GQL within Fluent. We will be using fulfilments
Author:
Fluent Commerce
Changed on:
13 Dec 2023
Key Points
- Example on how to use fragments in GQL
Steps
Here is the standard query GQL to get the fulfilment data:
Here is the standard query GQL to get the fulfilment data:
returning result

create 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
GQL with fragment returning result

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
Nested Fragments
We can even have fragments in the fragment. For example, create a new fragment on order Items:
nested Fragment result
