Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Graphql Client API in AEM Java | AEM Community Blog Seeding




Graphql Client API in AEM Java by AEM Queries & Solutions


Today lets see how we can make a graphql call from our AEM Java servlet to magento server and get the response.

In my previous article we saw how to call a servlet using resourceType. So same way we will create a servlet using resourceType and add the cq:graphqlClient – (String) – default property to the resource node.

Once we are done defining the client for that resource we will go to our servlet and get the client out of the request.

GraphqlClient graphqlClient = request.getResource().adaptTo(GraphqlClient.class);

Once I have the client object in place. We will now form the query(String) using com.adobe.cq.commerce.magento.graphql.Operations API or you can always define it as a simple String.

For example, we have a below query to get country codes:

String query = Operations.query(q -> q.countries(s ->;

Now we will maintain a pojo class for the type of queries that we want to execute. So as in above case we want countries code. So we will define countries getters and setters in that class. Lets say we name that class as QueryType which will have below declaration with respective getters and setters.

public class QueryType{
private JsonElement countries;

public JsonElement getCountries() {
return countries;
public void setCountries(JsonElement countries) {
this.countries = countries;

Read Full Blog

Graphql Client API in AEM Java


Please use this thread to ask the related questions.


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

0 Replies