REST and GraphQL really aren't that different
github.com
github.com
You can see some oData examples here: https://www.odata.org/getting-started/basic-tutorial/#reques...
This.
Sometimes I wonder if graphql proponents either are unaware of established REST strategies and tooling or if they intentionally turn a blind eye .
But I'd love to see an REST-based GraphiQL equivalent to prove this wrong: https://github.com/graphql/graphiql
batch means you can do things like combine these:
GET /serviceRoot/Airports GET /serviceRoot/People
into one request (and get the results in one response)
I believe that's what the poster was asking.
Here's a link to a different example from the OData site: https://www.odata.org/getting-started/advanced-tutorial/#bat...
You're using the word "join". I'm not sure if you meant that in a relational sense or not. If yes, then maybe you're wondering if you can get airports with their related people, or people with their related airports in one request with OData. Again, the answer is yes.
The oData contract, $metadata, describes an entire domain model, including associations between entities. You can use expand to join entities over these associations.
You can request multiple queries in one http operation using batch requests: https://www.odata.org/getting-started/advanced-tutorial/#bat...
Otherwise I could claim ISAM is just like a SQL database because MySQL is a SQL database built on top of ISAM.
To be fair, I feel like this fact means GraphQL does sit at a higher level of abstraction than "vanilla REST", which does make them not-so-comparable.
This fact should be emphasized. REST is just an architectural style, and it's absurd to claim that an architectural style bars developers from implementing specific functionalities.
It's even more absurd to compare a very specific implementation of a specific interface with an architectural style used to design and implement interfaces.
It seems to me that this whole GraphQL vs REST debate has absolutely nothing to do with REST or even HTTP APIs, and is actually a discussion about how reusing a ready-made solution developed by third-parties has some advantages over having to roll your own.
GraphQL is basically just a generic resource representation for queries.
[0] Like the one proposed here: https://www.ietf.org/id/draft-snell-search-method-01.txt
For instance, we have various REST-style endpoints that execute GQL queries directly on the backend.
If anything it's the other way around really, HTTP is tied to REST, but even that would be a misnomer. HTTP is an implementation of the architectural style REST, and undoubtedly the most popular in terms of application. There are others though, such as CoAP for example.
Ended up implementing it in REST.
It is possible to imbed types within types in GraphQL I.e.
Post {
Comments {
Comments
}
}It looks like we'll need to give clients more support in manipulating JSON, conversion to tabular data and help with pagination. There's a business opportunity for apps that help non-coders deal with GraphQL queries and results.
As in: absolutely different, and GraphQL breaks nearly everything that makes REST REST.
Pretending it's not in the server-side code doesn't make it "not different".
Ok. It doesn't break all of REST's semantics and ideas. "Only" the entirety of 5.2.1 and and most of 5.3 in the dissertation
It looks impressive in software interviews, but I don't really see the use in it for production code. Not every JS dev immediately knows what's going on with this syntax.
Therefore:
1 - this.mutation = this.get // returns this.get
2 - this.query = <return value of this.mutation = this.get, which is this.get>
3 - this.patch = <return value of this.query = this.mutation = this.get, which is this.get>
n - and so on...
Essentially, it's setting 6 different properties all to the same value.
---
EDIT: Here's the same concept, but in a different context...
function fibonacci(num, memo = {}) {
if (num <= 1) return 1;
if (memo[num]) return memo[num];
return memo[num] = fibonacci(num - 1, memo) + fibonacci(num - 2, memo);
}On the return line, the right-to-left property of "=" forces the extreme right to be processed first. It returns the recursive call.
Then, the return value of this recursive call gets saved to "memo[num]".
Finally, the return value of "memo[num] = fibonacci(...) + fibonacci(...)", which is still the same return value from the recursive call, gets saved to the function return.
Like if you wanted to return a empty hash {} for:
GET /
DELETE /
PUT /
PATCH /
POST /
I guess just being lazy.The biggest potential use case here would be to allow the server to expose a REST-style API as well as a GraphQL one with the same codebase - is that supported by this package? IMO it definitely should be.
The only other reason I can think of to use this is if you are used to writing express servers and don't want to change, which isn't a very good reason to use yet another package. graphql-tools makes writing the server pretty dead easy.
It's also nice that it's more standardized than a REST API - I know that if I need to work with a GraphQL api, I can look at the schema and immediately know how all the pieces fit together and how to get what I need.
app.get('/user', (req, res) => {
app.post('/createUser', (req, res) => {
These aren't what I'd consider to be RESTful... these seem more like traditional RPC calls.
If it returns error messages with a 200 OK status, then it's not restful at all ( https://github.com/graphql/graphiql/issues/88 )
I think this creates a bad convention of creating a service layer dependency on express where it's not needed.
As a proof, I like the idea, but in design I don't like adding extra coupling where it's not needed.
One of the power of GraphQl is allowing us to specify how much or how little of the result objects we want. For example, a Blog post on a mobile app might just want only the short synopsis of the comments and the poster's name, while a web view might want the whole comment.
Some funky abstraction over express.js server code looks similar for a trivial use case - that’s nice. But it’s ultimately nothing like REST under the hood.