GraphQL Fragments Result in Null | Community
Skip to main content
June 17, 2023
Solved

GraphQL Fragments Result in Null

  • June 17, 2023
  • 2 replies
  • 2021 views

Hello, I was testing GraphQL Fragments https://graphql.org/learn/queries/#fragments in the Headless Demo on Cloud and noticed that they don't allow for any data to be returned. The _path returns, but ONLY if it is also listed under "item" as well. All the other fields return null. It doesn't seem that GraphQL fragments work. Is this a bug?

 

{ adventureByPath( _path: "/content/dam/aem-demo-assets/en/adventures/bali-surf-camp/bali-surf-camp" ) { item { doda:_path ...adventure } } } fragment adventure on AdventureModel { _path title description { json } primaryImage { ... on ImageRef { _path width height } } }

 
The output

{ "data": { "adventureByPath": { "item": { "doda": "/content/dam/aem-demo-assets/en/adventures/bali-surf-camp/bali-surf-camp", "_path": "/content/dam/aem-demo-assets/en/adventures/bali-surf-camp/bali-surf-camp", "title": null, "description": null, "primaryImage": null } } } }

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by EstebanBustamante

It is worth noting that the AEM GraphQL API should not be confused with GraphQL itself. The AEM GraphQL API was not fully developed and some features, such as Mutations, Subscriptions, and Paging/Sorting, were still in progress at the time. Unfortunately, I am uncertain if this behavior is intentional or not. 

2 replies

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
June 19, 2023

It is worth noting that the AEM GraphQL API should not be confused with GraphQL itself. The AEM GraphQL API was not fully developed and some features, such as Mutations, Subscriptions, and Paging/Sorting, were still in progress at the time. Unfortunately, I am uncertain if this behavior is intentional or not. 

Esteban Bustamante
nitinkaushik
February 8, 2024

Is it yet to be made available in AEM, can someone please confirm ?