# GraphQL - can it be used with the Web API?

**URL:** https://community.thunkable.com/t/graphql-can-it-be-used-with-the-web-api/1473067
**Category:** Questions about Thunkable X
**Tags:** webapi
**Created:** [August 27, 2021, 5:19pm UTC](https://community.thunkable.com/t/graphql-can-it-be-used-with-the-web-api/1473067 "2021-08-27T17:19:16Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![hdawc](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/hdawc/32/119068_2.png) [@hdawc](https://community.thunkable.com/u/hdawc)
#### Post date: [August 27, 2021, 5:19pm UTC](https://community.thunkable.com/t/graphql-can-it-be-used-with-the-web-api/1473067/1 "2021-08-27T17:19:17Z")

</div>

I setup Hasura and created the databases, GraphQL works great and returns all data and user related data in \<25ms

What I need to know is if I can use the WebAPI to get this data as I seem to have some missing information where obviously I can’t use GraphQL in place of JSON in a API query (at least it won’t work that way on Postman and I know Postman has GraphQL features, but as Thunkable has the WebAPI, I need to submit GraphQL as one would a normal API.

Anyone know how?

Thanks.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [August 27, 2021, 5:41pm UTC](https://community.thunkable.com/t/graphql-can-it-be-used-with-the-web-api/1473067/2 "2021-08-27T17:41:25Z")

</div>

Technically, you can.  
You need to use `POST`. In the header assign `application/json` to the `Content-Type`. Your data query should go in the body.

---

<div class="post-metadata">

### Author: ![hdawc](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/hdawc/32/119068_2.png) [@hdawc](https://community.thunkable.com/u/hdawc)
#### Post date: [August 27, 2021, 6:19pm UTC](https://community.thunkable.com/t/graphql-can-it-be-used-with-the-web-api/1473067/3 "2021-08-27T18:19:59Z")

</div>

Hi thanks, I was actually aware of that part, the issue I’m having is how to wrap the GraphQL in the standard JSON query?

okay update I found it, the GraphQL is:

```auto
query MyQuery {
  lb_users(where: {email: {_eq: "name@example.com"}}) {
    email
    first_name
    last_name
  }
}

```

Which becomes:

```auto
{
    "query" : "MyQuery { users(where: {email: {_eq: \"name@example.com\"}}) {email first_name last_name}}"
}

```

Basically it can’t be JSON it has to be text with a backslash for any quotes

---

<div class="post-metadata">

### Author: ![hdawc](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/hdawc/32/119068_2.png) [@hdawc](https://community.thunkable.com/u/hdawc)
#### Post date: [August 27, 2021, 7:36pm UTC](https://community.thunkable.com/t/graphql-can-it-be-used-with-the-web-api/1473067/4 "2021-08-27T19:36:22Z")

</div>

What I’m struggling now with is the mutations (updates) I use the same process as above to create:

```auto
{"mutation" : "MyMutation {update_users(where: {email: {_eq: \"name@example.com\"}}, _set: {password: 12345678}){returning {updated_at}affected_rows}}"
}

```

But I get:

```auto
{
    "errors": [
        {
            "extensions": {
                "path": "$",
                "code": "parse-failed"
            },
            "message": "the key 'query' was not present"
        }
    ]
}

```

I’m just not sure where to add the key ‘query’.

I appreciate this is somewhat off topic for the Thunkable forums, but I think these kinds of self-host super-fast databases would be very useful for people if we could make sense of them enough to create tutorials on this forum.

---

<div class="post-metadata">

### Author: ![hdawc](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/hdawc/32/119068_2.png) [@hdawc](https://community.thunkable.com/u/hdawc)
#### Post date: [August 27, 2021, 7:43pm UTC](https://community.thunkable.com/t/graphql-can-it-be-used-with-the-web-api/1473067/5 "2021-08-27T19:43:21Z")

</div>

So I have also found the answer for Mutations.

One would simply wrap the mutation in a query:

```auto
{"query" : "mutation {update_users(where: {email: {_eq: \"name@example.com\"}}, _set: {password: 12345678}){returning {updated_at}affected_rows}}"
}

```

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [August 27, 2021, 7:58pm UTC](https://community.thunkable.com/t/graphql-can-it-be-used-with-the-web-api/1473067/6 "2021-08-27T19:58:47Z")

</div>

> [@hdawc](#):
>
> I appreciate this is somewhat off topic for the Thunkable forums, but I think these kinds of self-host super-fast databases would be very useful for people if we could make sense of them enough to create tutorials on this forum.

I wish that APIs were more standardized. The tricky thing is that each one is so different from every other. There are definitely things you can learn and then apply to other APIs but it’s almost never the case – at least for me – that you get to a place where you feel like an expert on APIs.

Even with the [tutorial](https://community.thunkable.com/t/api-json-tutorial-video/1140575) I made (and I’m a teacher and specifically tried to make it as broadly applicable as possible), it probably would barely have even helped you with this.

That being said, this forum is a great place to grow our knowledge and hey, maybe you’ll contribute a tutorial on this specific issue and people will benefit from that info.

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:17pm UTC](https://community.thunkable.com/t/graphql-can-it-be-used-with-the-web-api/1473067/7 "2024-11-08T13:17:12Z")

</div>


