How do I query the GraphQL endpoint with Axios/Got?

I’m a trying to use the GraphQL api. My queries work in graphiql, but no where else.

I’m using:

Whether I use Got or Axios, neither works. Also, neither allows sending a body/query in a GET request, but I still get errors when I use POST. I’ve gotten one 400 error if that helps at all.

This is my Got code:

(async () => {
  try {
    const body = await"", {
      headers: {
        Authorization: process.env.ACCESS_TOKEN,
        "Prismic-Ref": "master",
        ref: "master",
      body: `query{
      // ...a query that works in the graphql explorer for my repo...
      responseType: "json",

  } catch (e) {

Could you use an actual GraphQL client, like Apollo? GraphQL queries aren’t just the raw query string, it’s a JSON object with other things added.

Hi @daniel.mon.johns, I’m not sure about this, so I’ll have to pass it over to our @team-tech-support. Someone there will look into this as soon as they are able and get back to you with what they find.

At the end of the day, they are POST’ing the JSON to the server and receiving a response. I wanted to use a lighter solution because I’m using 11ty and not a full SPA.
Are my URL and headers correct at least?

Right, but you’ll need to send it to Prismic like this:

const query = `query {
  allPages {

fetch('https://<repository>' + encodeURIComponent(query), {
  headers: {
    'Prismic-ref': '<prismic ref>'
}).then(r => r.json()).then(console.log)

When you get to using variables, it might be more hassle than it is worth.

Doesn’t work. I even made my repo public

const query = `query that works in graphqil`
  url: `https://<my-repo>${query}`,
// I also tried encodeURIComponent(query)
  method: "get",
  headers: {
    "Content-Type": "application/json",
    // Authorization: auth,
    "Prismic-Ref": "master",
    // ref: "master",
  .then((result) => {

Any news? They haven’t gotten back to me.

Hey @daniel.mon.johns, have you tried running the query from the explorer?

If you go to https://<your-repo>, you should see a GraphiQL browser.

I know that the dev team is tracking this. I don’t have an ETA on when they will be able to look into it, but be assured that it is in their queue.

Someone will reach out to you when they pick this up.

Yea, my query works in GraphiQL, but everywhere else I get this now:
Query does not pass validation. Violations:↵↵Cannot query field 'hero'

Hey Daniel,

We are going to test this with Axios to see if it works. In the meantime, is there any reason you aren’t using the recommended Client for GraphQL queries?

This users website is a good example of how it works: