Use msg.payload in graphql node

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 ?

According to the documentation (see the node's flows library page: 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.

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}})
}

Try removing the msg. part.

it does not work as well. But thanks.

What happens if instead you try

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

Or perhaps easier readable:

{
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

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.