Expand my Community achievements bar.

SOLVED

GraphQL Fragments Result in Null

Avatar

Level 1

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
      }
    }
  }
}

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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

Avatar

Level 1

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