Hello,
Whenever I try to include graphQL fragments in my query the values return null. First example shows results without graphQL fragment, second shows results with it. Note that the content fragments are the same for both instances, so the null should have something populate.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @jlepore30
The AEM GraphQL API, while based on standard GraphQL, has areas that are still under development. Features such as mutations, subscriptions, and comprehensive support for fragments may not function as expected, leading to null values in query responses.
Solutions:
Avoid Using Fragments: To ensure consistent data retrieval, structure your GraphQL queries without using fragments. By explicitly specifying the required fields in each query, you can bypass the limitations associated with fragment usage in AEM's current GraphQL implementation.
Regards,
Views
Replies
Total Likes
The query syntax is like this
items {
pageCtaReferences {
... on ButtonWithLogicModel {
buttonId
buttonLabel
}
}
}
Here is a similar example of my query that populates the reference fragment values
Views
Replies
Total Likes
Thanks for the response @sarav_prakash . That is what I typically use on bigger pages as well. I am trying to use these graphql fragments so that I don't have to repeat '...on buttonWithLogicModel' three different times on the same query.
Like this - https://hygraph.com/learn/graphql/fragments
understood. I too tried with fragment instead of spread operator and my query works again. Your fragment paths are all right, dont find anything wrong.
Just to ruleout, my cfm modal path doesnt have too many hyphens like yours `/button---with-logic`. Can you try simple modal like `/buttonwithlogic` just to ruleout hyphens are not causing noise?
Views
Replies
Total Likes
Hi @jlepore30
The AEM GraphQL API, while based on standard GraphQL, has areas that are still under development. Features such as mutations, subscriptions, and comprehensive support for fragments may not function as expected, leading to null values in query responses.
Solutions:
Avoid Using Fragments: To ensure consistent data retrieval, structure your GraphQL queries without using fragments. By explicitly specifying the required fields in each query, you can bypass the limitations associated with fragment usage in AEM's current GraphQL implementation.
Regards,
Views
Replies
Total Likes
Thank you @Shiv_Prakash_Patel
Views
Replies
Total Likes
In short, if your GraphQL fragment is returning null, try the following:
These steps should help you pinpoint the issue with the fragment returning null.
Views
Replies
Total Likes
Views
Likes
Replies