1

I am trying to build a framework around monday.com API. Following statement works:

var query = @"{""query"": ""mutation {create_item(board_id: 1111, group_id:\""new_group\"", item_name: \""adding works\"", column_values: \"" {\\\""long_text\\\"": { \\\""text\\\"": \\\""Sample text\\\""}} \"") {id}  }"" }";

All the escaping is not er super fluid way of working. Is there a better and more readable way?

But it is a nightmare to work with all this escaping. All input are welcome. Especially when I want to build the query dynamically.

Thomas Segato
  • 4,567
  • 11
  • 55
  • 104

1 Answers1

0

you can compose GraphQL query with variables. This is a good way how to make your queries dynamic and to overcome double escaping.

More information about it here: https://graphql.org/learn/queries/#using-variables-inside-fragments

There is a tutorial for composing monday GraphQL query with variables here: https://support.monday.com/hc/en-us/articles/360013465599-API-Quickstart-Tutorial-Javascript ("Creating a new item using GraphQL variables" section)

  • Thanks for fast response. Not sure how this relates specific to c#? – Thomas Segato Aug 31 '20 at 14:31
  • GraphQL variables are in concept of GraphQL in general, which allow you to send variables outside of your query to not have the problem of double quotes escaping. There is https://graphql-dotnet.github.io/docs/getting-started/variables/ this library which can help you with using GraphQL variables in C# – Vlad Mystetskyi Sep 01 '20 at 18:26
  • Makes sense. Thanks. – Thomas Segato Sep 02 '20 at 08:17