How to run direct graphql queries without persistentQueries | Community
Skip to main content
sarav_prakash
Community Advisor
Community Advisor
January 11, 2025

How to run direct graphql queries without persistentQueries

  • January 11, 2025
  • 3 replies
  • 1197 views

Is there documentation to run vanilla graphql queries using say ApolloClient?

In my usecase, my content fragment schema has 350+ elements in it. UI Head is a reporting react app, allows users to choose columns and graphql query must load results. Page load pulls only 10 elements and allows users to dynamically add more elements.

 

With this reporting page, persistentQueries wont help me. The query must fetch all 350 elements and then UI must filter interested elements. Looking for a way to construct queries at client using Apollo and run. 

 

Documentation reads ability to run direct direct queries may get deprecated. 

Until we too migrate content fragments into better solutions, looking for running direct queries. Is there documentation how to implement? 

 

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

3 replies

Uppari_Ramesh
Level 5
January 12, 2025

Hi @sarav_prakash .

 

Please open the graphql editor console and type the query with all the elements and open the network tab and then run the query then you should be able to see a api call in the network tab which internall calls graphql endpoint with the requested elements.

 

This way you need not to use persistent query and you can directly call the graphql endpoint without using persistent query. This is what hitting the graphql with direct queries.

sarav_prakash
Community Advisor
Community Advisor
January 12, 2025

agreed. hacky way indeed works. Was looking for list of osgi config, dispatcher, env variables etc to run query at publisher upto production. 

Documentation provides how to get started 

And I was able to resolve schema 

But still working to figure dispatcher and publisher osgi config. 

 

Was checking if anyone have done this in their project successfully. 

PRATHYUSHA_VP
Community Advisor
Community Advisor
January 13, 2025

Hi @sarav_prakash 

 

In our project use-case we are using graphQL headless client which fetches all results in NextJs based front-end application

 

https://experienceleague.adobe.com/en/docs/experience-manager-learn/getting-started-with-aem-headless/how-to/example-apps/react-app

 

There is a java based implementation as well for the same

 

https://github.com/adobe/aem-headless-client-java

 

Check if it helps for your use-case

 

Thanks

 

 

 

sarav_prakash
Community Advisor
Community Advisor
January 13, 2025

Thanks, I ll try this. Examples show hitting publisher. Are you hitting direct publisher or through dispatcher? What all changes needed at publisher and dispatcher to enable this?

PRATHYUSHA_VP
Community Advisor
Community Advisor
January 15, 2025

Need to enable GraphQL pre-caching within AEM and need to configure dispatcher and CDN cache for improved performance

 

You can check below -

 

https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/headless/deployment/dispatcher

 

https://techrevel.blog/2023/10/09/faqs-about-implementing-headless-using-content-fragments-and-graphql/

 

Hope it helps !

 

 

kautuk_sahni
Community Manager
Community Manager
January 27, 2025

@sarav_prakash Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Kautuk Sahni