import { fetch } from "../../api/fetch"

export const graphqlAPI = (url: string, query: string) =>
  fetch(`${url}/api/graphql`, {
    method: "POST",
    body: JSON.stringify({ query }),
  })
    .then(res => {
      if (res.ok) {
        return res.json()
      } else {
        throw new Error("HTTP error\n" + JSON.stringify(res, null, "  "))
      }
    })
    .then(body => {
      if (body.errors) {
        // tslint:disable-next-line:no-console
        console.log("Received errors from the GraphQL API")
        // tslint:disable-next-line:no-console
        console.log(body.errors)
      }
      return body
    })

import { fetch } from "../../api/fetch"

export const graphqlAPI = (url: string, query: string) =>
  fetch(`${url}/api/graphql`, {
    method: "POST",
    body: JSON.stringify({ query }),
  })
    .then(res => {
      if (!res.ok) {
        return res.json()
      } else {
        throw new Error("HTTP error\n" + JSON.stringify(res, null, "  "))
      }
    })
    .then(body => {
      if (body.errors) {
        // tslint:disable-next-line:no-console
        console.log("Received errors from the GraphQL API")
        // tslint:disable-next-line:no-console
        console.log(body.errors)
      }
      return body
    })

--- 
+++ 
@@ -6,7 +6,7 @@
     body: JSON.stringify({ query }),
   })
     .then(res => {
-      if (!res.ok) {
+      if (res.ok) {
         return res.json()
       } else {
         throw new Error("HTTP error\n" + JSON.stringify(res, null, "  "))
Fix booleab logic in the error handling
