Expand my Community achievements bar.

Introducing Adobe LLM Optimizer: Own your brand’s presence in AI-Powered search and discovery
SOLVED

How to retrieve all fields that are available in content fragment model ?

Avatar

Level 9

I have created a content fragment that contains multiple fields, and I am trying to retrieve all of them using GraphQL.  I want to like to avoid listing each field individually. For example if my content fragment has 20 fields, I want to extract and view all field values without specifying them one by one. Is there a way to achieve this? I attempted using an asterisk (*), but it did not work. I also tried GraphQL introspection, but that did not yield any results. Any suggestions?

 

 

{
  testFragmentByPath(_path:"/content/dam/projects/en-us/1",variation:"master") {
    item{
      h1text
      h2text
      buttonText
    }
  }
}

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 3

Hi @Mario248 ,

GraphQL by design is meant to be explicit about the fields. So you can't do something like 'select *' in graphql like we do in databases.

Here's a link explaining the same which goes into more details-https://productionreadygraphql.com/blog/2019-10-24-why-you-cant-select-all-fields-on-a-type-in-graph... 

View solution in original post

2 Replies

Avatar

Community Advisor

Hi @Mario248 

 

In the GQL editor, it will not allow to query for the equivalent of (*)

 

You should specify the fields what is required to display in the final output

 

Hope this helps

Avatar

Correct answer by
Level 3

Hi @Mario248 ,

GraphQL by design is meant to be explicit about the fields. So you can't do something like 'select *' in graphql like we do in databases.

Here's a link explaining the same which goes into more details-https://productionreadygraphql.com/blog/2019-10-24-why-you-cant-select-all-fields-on-a-type-in-graph...