Crafting a GraphQL Query

This is a “mini-guide” on crafting GraphQL requests with Make. I continued to find information that was incomplete, incorrect, or partially accurate - so I wanted to create this as a resource to help my future-Googler, and hopefully assist some others banging their head on the table.

More and more APIs seem to be switching over to GraphQL, and while I’m learning to love it - I’m still finding it regularly finding it to be a head-scratcher and a lot of documentation to be non-obvious.

Anyway - here’s to crafting a GraphQL query in Make. I expect this won’t work for everyone, but so far it’s worked for all of my requests on all platforms.

Create a new HTTP Module

  1. Set your request URL (Unlike REST, this is likely a single API endpoint for all requests
  2. Set your Method (May or may not matter. In my case, any have worked)
  3. Set your Headers (API keys likely going here)
  4. Select Application/x-www-form-urlencoded as your Body type
  5. Set your Fields
    1. Item 1
      1. Key: query (Note: This will be query regardless of whether it is a query, mutation, subscription, webhook, or any other top-level entry that your platform uses
      2. Value: `[Your actual GraphQL query. This should not be JSON, but should be a plain query - same as what would work inside of GraphiQL or another GraphQL IDE
    2. Item 2
      1. Key: variables
      2. Value: `[Your actual GraphQL variables. This should not be JSON, but should be a plain query - same as what would work inside of GraphiQL or another GraphQL IDE
  6. Set Parse response to Yes (Optional - but recommended as I feel it makes the response easier upon inspection + if you’re going to run it through a JSON parser later anyway saves a step.

Hope that helps some others!

7 Likes

Hey @TJ :wave:

Thank you so much for summarizing and sharing your mini-guide with us here! I am sure that it will be helpful for many of our users! :pray:

Keep up the amazing job!

2 Likes

Thank you for the great insights. My setup was slightly different and also worked for queries and mutations.

5 Likes

This is a life saver ! Thank you so much, I spent hours trying to figure out why it wasn’t working!

2 Likes

Glad it helped! As I’m continuing to work with more GraphQL APIs, I’m also learning that not all are working the same. Which is very frustrating! You can see @jtraderj 's earlier response as an example.

Currently, I just came across one (Shopify GraphQL) that only accepts those with an ‘application/json’ format and the query must go in the body - and apparently upon doing so, you’ll need to ensure that all data is on a single line, and any quotes are also escaped - which makes it a bit annoying to write something properly formatted on the module.

Hope others can continue to contribute some other edge-cases here if they come across them :slight_smile:

Thank you for this, however the 2025-01 version doesn’t seem to accept the application/graphql content type. Do you have a way to do this using the the 2025-01 API version by chance? Thanks again!

I got it to work this way, just an FYI.