f / graphql.js

A Simple and Isomorphic GraphQL Client for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Direct query execution using async await

corstian opened this issue · comments

According to documentation it is possible to execute queries using the following approach:

graph(`query ($email: String!, $password: String!) {
  auth(email: $email, password: $password) {
    ... auth # if you use any fragment, it will be added to the query.
    ... error
  }
}`, {
  email: "john@doe.com",
  password: "my-super-password"
}).then(function (response) {
  // response is originally response.data of query result
  console.log(response)
}).catch(function (error) {
  // response is originally response.errors of query result
  console.log(error)
})

I have been using this approach in the following way using the async await syntax.

await graph(`query`, { })

However, while this worked in version 0.4.20, I haven't been able to get it to work using version 0.6.5.

Is there something I'm overlooking, or has this approach been deprecated?

Related to #40. Closing.