Expand my Community achievements bar.

Join us in celebrating the outstanding achievement of our AEM Community Member of the Year!

How to run direct graphql queries without persistentQueries

Avatar

Level 7

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. 

sarav_prakash_0-1736628859958.png

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

 

Topics

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

5 Replies

Avatar

Level 4

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.

Avatar

Level 7

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 

sarav_prakash_0-1736720945517.png

And I was able to resolve schema 

sarav_prakash_1-1736721038191.png

But still working to figure dispatcher and publisher osgi config. 

 

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

Avatar

Level 6

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-headles...

 

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

 

 

 

Avatar

Level 7

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?