- Difficult to scale REST-ful conventions out to nested sets of data.
- When dealing with normalized data, retrieving state likely ends up requiring multiple HTTP requests.
- Usuallys returns all data associated with a particular model, even if the consumer doesn't need this data.
- Follow RESTful conventions strictly, issue multiple HTTP requests, and force the consumer to compose the data together
- Develop more sophisticated backend routes that nest using RESTful conventions, simplifying the API for the consumer but increasing backend complexity
- Abandon RESTful conventions and create a custom routes that feeds the precise need by a particular application use case
Also, usually a route will return all of the data associated with a particular model, even if the consumer doesn't need this data, which increases network payload.
GraphQL wants to simplify RESTful routing and reduce oversharing
Graph models our data using a Graph Data Structure of
- Nodes
- Relations (called edges)
GraphQL Query
What are the names of the companies where users connected to user 23 work?
query {
user(id: '23') {
users {
company {
name
}
}
}
}
+++++++++++++++++++++++ +++++++++++++++++++++++ +++++++++++++++++++++++
+ GraphiQL front-end + => + GraphQL Server + => + Mock Discovery Src +
+++++++++++++++++++++++ +++++++++++++++++++++++ +++++++++++++++++++++++