Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Is the graphql syntax inspired by the json syntax?


Asked by Robin Preston on Dec 12, 2021 JSON



In fact, the GraphQL syntax is partly inspired by the JSON syntax. While there's nothing that prevents a GraphQL service from being versioned just like any other REST API, GraphQL takes a strong opinion on avoiding versioning by providing the tools for the continuous evolution of a GraphQL schema.
Additionally,
80122 gold badges1313 silver badges3333 bronze badges 1 The best definition of the wire protocol I've seen is on the graphql.org site. There is not a standard translation of the GraphQL query syntax into JSON; you pass the query string as a JSON string in a small object wrapper.
Moreover, In conclusion, GraphQL queries cannot be easily represented in a single-line, in such a way that we humans can make sense of it, because of its nesting behavior. The issue is not specific to GraphQL. Indeed, it will happen for a syntax — any syntax — where the elements advance and retreat. Take JSON, for instance:
Accordingly,
JSON may seem like an odd choice for an API layer promising better network performance, however because it is mostly text, it compresses exceptionally well with GZIP. It's encouraged that any production GraphQL services enable GZIP and encourage their clients to send the header:
In fact,
GraphQL comes with a default set of types, but a GraphQL server can also declare its own custom types, as long as they can be serialized into your transport format. Read more about the GraphQL type system here.