Calling GraphQL API using Mulesoft
To call GraphQL API, we don't need to use any specific connector, we can use the Request operation from HTTP connector. GraphQL API's are consumed with HTTP POST request. For this demo we will be consuming https://api.spacex.land/graphql/
The payload body for POST Request should be JSON object containing properties - 'query' and 'variables'. The 'query' is your GraphQL query and variables are variables that are referenced in this 'query'.
Step 1: Create a New Mule project which listens to GET on /graphql
Step 2: Prepare the payload to the request component containing properties 'query' and 'variables'.
Step 3: Configure Request from HTTP connector for POST to your GraphQL API URL with payload set to payload prepared in Step 2.
Run your project and call your API through Postman. You will be able to see response -