Level 1
Level 2
Melden Sie sich an, um alle Badges zu sehen
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.
Gelöst! Gehe zu Lösung.
Anhand von Themen werden Community-Inhalte kategorisiert und Sie können so relevanten Inhalt besser finden.
Zugriffe
Antworten
Likes gesamt
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,
Zugriffe
Antworten
Likes gesamt
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
Zugriffe
Antworten
Likes gesamt
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?
Zugriffe
Antworten
Likes gesamt
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,
Zugriffe
Antworten
Likes gesamt
Thank you @Shiv_Prakash_Patel
Zugriffe
Antworten
Likes gesamt
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.
Zugriffe
Antworten
Likes gesamt
Zugriffe
Likes
Antworten
Zugriffe
Likes
Antworten