Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

AEM 6.5 Graphql persistent query use with Java Apollo client

Avatar

Level 4

Hi,

 

We are trying to consume the persistent query created in AEM inside the Java backend code using the Apollo Graphql client. The persistent query is working fine directly in the browser as well as Java backend codebase is fetching the result for a normal graphql query with the Post request but somehow throwing an error for the persistent query with the Get request. Wondering if anyone consumed persistent queries with the help of the Apollo Graphql client and provide some sample code?

 

Thanks.

Mukesh 

5 Replies

Avatar

Community Advisor

@MukeshAEM Could you please also specify what is the error that you are getting?

Avatar

Level 4

@Manu_Mathew_ , Apollo client supports automatic persisted queries. AEM has queries already persisted with a given name and does not accept the query passed on by the client which has the list of variables and a hash for the query. Once this is persisted on the server end, further calls from the client would only include the variables and the hash. Wondering if AEM supports such a feature for persistence where it accepts the queries from the client and stores the hash? 

Avatar

Employee Advisor

@MukeshAEM Do you have any query parameters being passed to the Persistent Query?

If yes, can you post the snippet with GET request?

Avatar

Level 4

Hi @krati_garg , Yes, we need to pass a few parameters. It seems the Apollo client doesn't provide the option to perform Get request to a persistent query. We were able to consume it using a regular Rest call. Ask is if someone has used the Apollo client to call persistent queries and provide some code snippets.

Avatar

Employee Advisor

@MukeshAEM Can you try the query with ; instead of ? for query parameters