Why is GraphQL not designed to be a valid json document?
I wonder why facebook has invented new markup for GraphQL instead of json. Many rest api provide some query functionality like json-based query or json-rpc, or just using parameters.
I'm not trying to discuss, I'm just curious to find a motive.
I would say the main reason is simplicity. You just specify the fields in the requested form. With JSON, you need to write something like : true
, each line, you need to use the quotes property, commas, ...
In addition, you need to describe the arguments and snippets that will require additional customization of the JSON form.
With its own language, GraphQL can express itself more succinctly.
By the way, this kind of question might be better asked on Quora rather than SO.