In essence, GraphQL query is a grocery list of stuff you want. Response is a grocery bag of what you wanted.
From REST perspective, GraphQL is a union of multiple REST query URLs presented as JSON hierarchy, turning each path fragment into a nested object.
I think I understand how to `resolve` a path into a object. Array of objects should be similar, right? And how do I then describe that object with GraphQL terms? Can `resolve` function of fields get this object passed in?
It seems entity-centric though. What would a GraphQL 'mutation' look like that kicked off some process requiring the identity of say 3/4 entities plus some of its own input?
The big issue with OData is that it is highly flexible, and as such rather difficult to make cover all cases and keep it performant.
But maybe the real problem was simply that no good OData servers existed, barring the one from MS that tied directly with their ORM and thus your data model.
I really suspect that the flexibility that GraphQL gives immediately translates to complexity on the server side.
It feels like this is ORMs all over, just now between the frontend and the backend instead of the backend and the database. Give it a couple of years and we'll see the REST-version of the "just use plain SQL!" blog posts: "just hand-craft highly specific REST endpoints for exactly what your frontend needs!"
While GraphQL certainly shares some attributes with OData, we believe it is substantially different enough from Data that we aren't simply repeating the same mistakes.
There are a number of differences, but two in particular are striking.
1) Is that the GraphQL language is built with product developers in mind. This is a subjective/qualitative judgement, but we believe that it's just a much more elegant language, and that it is a more powerful platform for tool-building. We hope to prove this out in the coming months as both we and the community build tooling atop the language and the introspection system. 2) GraphQL is more constrained. A OData service has to support a huge number of operations that make it more of a generic querying service, rather than a highly structured way to expose application logic. We agree with you that often cover too much and without adequate performance guarantees.
In terms of complexity on the server side, I think this is a really legitimate question. Our answer is that although there is complexity, it is generally incurred on a much smaller set of core and tool developers. The average product developer who will just need to expose a capability via a GraphQL type and then consume it on the client will not find the system overly complex.
This sounds like you think more developers pay attention to what Facebook do than Microsoft. If that's the case then you are a long way off. A really long way.
It is in effect a filtering language. You have database view e.g. "user" and you apply it to the given GraphQL and get less fields than the view defined. In this way from server side you have still bunch of functions (the database views) that take in arguments (e.g. User ID) and GraphQL and the view returns the subset of the view.
Above is simple explanation I would try to implement GraphQL. Mutators are a different story I have not thought about.
We model mutations as a function that can do arbitrary business logic followed by a client-specified query where the client can query data it knows must be updated in order for the view to reflection the state changes the mutation caused.
GraphQL looks nice in theory, and surely in practice regarding Facebook's storage architecture, I just wish it can be used on smaller project with DB backed data.