Select N reasons of GraphQL
Originally released in the third border of the Institute szhshp , please indicate
Selected because it is the easy ah
GraphQL API type pattern having strong
GraphQL schema is a convention for indicating the API function.
- API defines a strict scheme operations supported (query, mutation, subscribe)
- API documentation automatically generates a corresponding schema, the setting becomes very easy backend API
Get on-demand, and strong expansion
This is very straightforward, wrote a front-end query, query which directly determines the required data
It solves two typical problems of traditional REST API: Overfetching and Underfetching
REST without relying on a fixed data structure returned from the server.
For
老式数据查询 API
fixed data structures returned, we even want to conduct additional processing front end
Overfetching
That return more data than the data I need
- Vintage API
- You have a fixed background may receive specific parameters returned by the database data parameter determination
- GraphQL
- I need to write data directly in front of the query request, so it will not spread too much data coming back
Underfetching
That return less data than the data I need
- Vintage API
- I probably need to get data at the request of an excuse
- In particular some of the data is similar to the connection
- For example, to obtain the user's data, and then need to get the user back each time a user requests data according to article
- So obviously it has requested several times
- GraphQL
- A request to get all
Support rapid product development
There are a lot of front-end framework for GraphQL support (Apollo, Relay, etc.)
There's even a tool such GraphQl Faker, so that before the schema can be encoded all good design
Composing GraphQL API
API splicing
Free to be spliced multiple API
And can be nested queries
There is a rich community
Express, a plurality of frames has a corresponding middleware
With debugging tools will continue to increase
I can not write code for SQL Server
This can also be counted as an advantage ah