Skip to main content
Level 2
March 9, 2023
Solved

Using GraphQL Queries in OSGi Services

  • March 9, 2023
  • 2 replies
  • 1043 views

We have complex and nested content model and corresponding fragments. We would like to use GraphQL to fetch the content from the content fragment and display in the website. 

Using OSGi Service or Sling Model, how can we execute a GraphQL query?

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

@naan_raja , Graph QL is used by application outside AEM to consume the content fragments thru Graph QL API by end points. AEM internally converts the Graph QL API call to SQL query and executes the query and sends the result. 

If you want to consume content fragments inside the AEM, i would think about using OSGI Service running querybuilder API or sling model to read the CFs. 

If you still want to consume the Graph QL API, you can make the java POST call to end points from services.

2 replies

Saravanan_Dharmaraj
Community Advisor
Saravanan_DharmarajCommunity AdvisorAccepted solution
Community Advisor
March 9, 2023

@naan_raja , Graph QL is used by application outside AEM to consume the content fragments thru Graph QL API by end points. AEM internally converts the Graph QL API call to SQL query and executes the query and sends the result. 

If you want to consume content fragments inside the AEM, i would think about using OSGI Service running querybuilder API or sling model to read the CFs. 

If you still want to consume the Graph QL API, you can make the java POST call to end points from services.

Level 2
March 10, 2023

@naan_raja  Try Post call using HTTP client with graphql query as stringEntity in your OSGI service and get the desired response.