There are so many people in this forum trying to debug string concatenation and badly escaped JSON in GraphQL queries.
If the documentation provided only the best quality examples of how to use GraphQL variables, it would save everybody’s time and lead to a much better developer experience.
Hey David,
That’s a great suggestion actually. noted!
For today, it would make it more complicated to copy&paste examples into the API playground.
So for now we would reccomend to use the AI assitant to convert the examples into different languages.
Just a note, over the last couple years, at least 20 times (an estimate of my OWN responses only) the solution to a thread has been to use GraphQL variables instead of string concatenation or string templates.
Also the javascript documentation examples are not written using the monday-graphql-api module, (or the now deprecated for API use, monday-sdk-js) which leads to confusion. The example use fetch and specify the token, and adds complexity vs using the seamless authentication supported by the official api/sdk modules. These examples then lead developers to think they have get a token, so they implement OAuth2 and store tokens. Instead of just using the seamless authentication. While using seamless is documented - most devs will not read the documentation start to finish, they will look at the examples and iterate on those. If the examples demonstrate bad practices, developers will implement and iterate on bad practices. This will lead to lower quality apps for the platform.
Oddly some of the JavaScript examples do use variables - but for column mutations they use a string for the variable used for column_values instead of showing an object being serialized using JSON.stringify(). This leads devs into using string concatenation or templates yet again!
Lastly, all the bad code examples are feeding the AIs. Garbage in, garbage out. This means AI is just going to propagate crap code further