# Use msg.payload in graphql node

**URL:** https://discourse.nodered.org/t/use-msg-payload-in-graphql-node/28466
**Category:** General
**Created:** [17 June 2020 11:16 UTC](https://discourse.nodered.org/t/use-msg-payload-in-graphql-node/28466 "2020-06-17T11:16:40Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Hattori](https://avatars.discourse-cdn.com/v4/letter/h/bb73d2/32.png) [@Hattori](https://discourse.nodered.org/u/Hattori)
#### Post date: [17 June 2020 11:16 UTC](https://discourse.nodered.org/t/use-msg-payload-in-graphql-node/28466/1 "2020-06-17T11:16:40Z")

</div>

hello,

i am using **node-red-contrib-graphql** to send queries to a graphql server. It works with the value directly write into the query, but i actually want to give values to the graphql node and use msg.payload to build the query.

I tried many solution but nothing works. So is it possible ?

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [17 June 2020 12:15 UTC](https://discourse.nodered.org/t/use-msg-payload-in-graphql-node/28466/2 "2020-06-17T12:15:06Z")

</div>

According to the documentation (see the node's flows library page: [https://flows.nodered.org/node/node-red-contrib-graphql](https://flows.nodered.org/node/node-red-contrib-graphql)), it allows the incoming `msg.payload` to be an object with properties that can be referenced in Mustache syntax, when you use the `query` field in the node as a template.  
I hope that helps. Beyond that, this node does not appear to offer that functionality.

---

<div class="post-metadata">

### Author: ![Hattori](https://avatars.discourse-cdn.com/v4/letter/h/bb73d2/32.png) [@Hattori](https://discourse.nodered.org/u/Hattori)
#### Post date: [17 June 2020 12:21 UTC](https://discourse.nodered.org/t/use-msg-payload-in-graphql-node/28466/3 "2020-06-17T12:21:34Z")

</div>

yes, that is why i don't understand why i can't make it work. my query works like this

> {  
> configure(name: "myName")  
> }

But if i do the following, it fails:

> {  
> configure(name: {{msg.payload.myName}})  
> }

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [17 June 2020 12:24 UTC](https://discourse.nodered.org/t/use-msg-payload-in-graphql-node/28466/4 "2020-06-17T12:24:59Z")

</div>

Try removing the `msg.` part.

---

<div class="post-metadata">

### Author: ![Hattori](https://avatars.discourse-cdn.com/v4/letter/h/bb73d2/32.png) [@Hattori](https://discourse.nodered.org/u/Hattori)
#### Post date: [17 June 2020 12:44 UTC](https://discourse.nodered.org/t/use-msg-payload-in-graphql-node/28466/5 "2020-06-17T12:44:30Z")

</div>

it does not work as well. But thanks.

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [17 June 2020 16:48 UTC](https://discourse.nodered.org/t/use-msg-payload-in-graphql-node/28466/6 "2020-06-17T16:48:51Z")

</div>

What happens if instead you try

```auto
{
configure(name: "{{msg.payload.myName}}")
}

```

Or perhaps easier readable:

```auto
{
configure(name: {{{msg.payload.myName}}})
}

```

The difference between double brackets and triple brackets is that double brackets just places the value in the template, while the triple brackets add in the raw value, including quotes on both sides of a string.

See the "Tag types" section of the Mustache manual: [https://mustache.github.io/mustache.5.html](https://mustache.github.io/mustache.5.html)

---

<div class="post-metadata">

### Author: ![Hattori](https://avatars.discourse-cdn.com/v4/letter/h/bb73d2/32.png) [@Hattori](https://discourse.nodered.org/u/Hattori)
#### Post date: [19 June 2020 14:28 UTC](https://discourse.nodered.org/t/use-msg-payload-in-graphql-node/28466/7 "2020-06-19T14:28:11Z")

</div>

i actually succed by adding en empty query in the graphql node with **{ }** and directly filling the **msg.template** with the query in previous function node. it works fine. But weird that i cannot simply pass payload.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [18 August 2020 14:28 UTC](https://discourse.nodered.org/t/use-msg-payload-in-graphql-node/28466/8 "2020-08-18T14:28:12Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
