Here’s an example how to use “Call REST” Activity for an GraphQL API. It uses a small custom java action (GraphQL query template 2 JSON) to transform a GraphQL query into a JSON query that can be Posted to a GraphQL endpoint.
You can call a GraphQL endpoint in the same way you’d call a regular REST endpoint. However, at this point Mendix doesn’t offer any assistance in building GraphQL queries, so you’d have to create the request body yourself and parse the response accordingly.
To add some more detail, the first screenshot shows an example of how you can do a GraphQL query in visual studio code with the rest plugin. GraphQL query on the left, the result HTTP call on the right. Notice that the graphql query needs to be rewritten into a valid json payload. The second example is the quick and dirty java demo code that does this for simple situations. Note that this is not extensively tested, and not fit for production…
Hi, just realized that I missed a basic step. I realized that I forgot to set a new HTTP header for Content-Type. Now getting the response.