Mustache template with node-red-contrib-graphql

I used a change node to set msg.payload.inventory_item_id to 42112828440781

Next I use the graphql node (from node-red-contrib-graphql) to run the following GraphQL query:

  inventoryItem(id: "gid://shopify/InventoryItem/{{inventory_item_id}}") {
    variant {
      product {

I set the node to use moustache templating. However, the {{inventory_item_id}} is being replaced with nothing. This results in the following error: "Invalid global id 'gid://shopify/InventoryItem/'"

The docs for node-red-contrib-graphql state:

If you select mustache, your template will be processed by Mustache with the message's payload as an argument. I.e.
submitted_template = mustache("template in text area", msg.payload)

Am I missing something?

Aha! I had to reference it as {{payload.inventory_item_id}}

Did I misunderstand the docs or are they wrong?

I have not used that particular contrib node, but if I recall correctly, the context of the core template node is the full msg object, not just the playload...

Have you tried this?


If that does work, then I guess the documentation just needs to be updated.
If not, then I have no idea ;*)

Jinx! nice catch

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