How to retrieve all fields that are available in content fragment model ? | Community
Skip to main content
Mario248
Level 7
February 14, 2025
Solved

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

  • February 14, 2025
  • 2 replies
  • 627 views

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

 

 

 

Best answer by NavyaSri_M

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

2 replies

PRATHYUSHA_VP
Community Advisor
Community Advisor
February 14, 2025

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

NavyaSri_MAccepted solution
Level 2
February 14, 2025

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