How do I send an unmodified string to a query template?

I use a graphql query:

mutation insertPlugin {
  insert_wps_plugins(objects: {active: false, name: "{{$node["Split Plugins"].json["name"]}}", slug: "{{$node["Split Plugins"].json["slug"]}}", description: "{{$node["Split Plugins"].json["description"]}}", short_description: "{{$node["Split Plugins"].json["short_description"]}}" type: "free"}) {
    returning {
      id
    }
  }
}

But if $node[“Split Plugins”].json[“description”] contains escape symbols \ all of this removed. How can I keep them unchanged in the request?

Welcome to the community @zorca!

Nothing in the code removes any escape characters. That is simply how JavaScript works. In JSON they have to get added that it is valid JSON and when the string gets output it gets “converted” again to what it actually is. For example does a \n get converted again to a newline what it is supposed to be. If you want it escaped you would have to do it by yourself withJSON.stringify.

So instead of:
{{$node["Split Plugins"].json["name"]}}
you would have to use:
{{JSON.stringify($node["Split Plugins"].json["name"])}}

Hope that helps!

1 Like