Queries with older JavaScript

If you are using a newer flavour of JavaScript you can do multiline literals using backticks like this

This gets concatenated to look like this

This makes building a JSON string that needs new lines very straightforward.

GraphQL

I’ve been using GraphQL with Apps Script for some time, but it can be a real pain to put together the queries, since GraphQL likes new newlines between fields – so if you have a query that needs to look like this

It’s quite a struggle to put together without backticks but you can recursively organize arrays or values quite simply.

And just a few lines of code

For more like this see Google Apps Scripts Snippets

For help and more information join our community, follow the blog or follow me on twitter