News for hackers. Stuff that matters.
Re:Migrating to GraphQL: A Practical Assessment by jahewson on Thursday July 04, 2019 @06:42PM (#20358378)
GraphQL was created at Facebook specifically for internal APIs. The motivator was to avoid having to write a custom endpoint for every single REST query, because otherwise REST is not efficient.

Note that GraphQL does not allow the specification of arbitrary queries - much like REST does not allow access to arbitrary resources - the sever defines what queries are available and the user can choose to request a selection of them, and to pluck data from them (or follow links - simply a JOIN).

In other words, GraphQL lets you combine a subset of pre-defined queries in one go.

Re:Migrating to GraphQL: A Practical Assessment by Horusiath on Friday July 05, 2019 @01:08AM (#20359986)
> GraphQL was created at Facebook specifically for internal APIs.

AFAIK Facebook created GraphQL specifically for their gateway API - a service used as a facade between internal service mes(s/h) and their client - not for internal ones themselves. That's why things like schema stitching didn't came from FB - they weren't using it in that context.

Re:Migrating to GraphQL: A Practical Assessment by tepidandroid on Friday July 05, 2019 @05:39PM (#20366093)
This is my understanding also.
Re:Migrating to GraphQL: A Practical Assessment by desc on Thursday July 04, 2019 @07:02PM (#20358483)
'Combine a subset of pre-defined queries': you mean run a bunch of queries and perform the join locally? Like a poorly-designed app server 're-using' several repository methods and doing joins in-memory?

I may be misunderstanding something here, but when 'general' queries are combined externally a lot more work is done than is necessary. Which may be fine for small intermediate sets. But treating it as any kind of general solution is silly.

That said, people do similarly stupid things within individual codebases running in individual services to a single database, so as usual it likely comes down to how the tool is used rather than how it can be abused. Still, spreading these things across services and processes looks like it only makes abuse easier.

Re:Migrating to GraphQL: A Practical Assessment by ivanhoe on Thursday July 04, 2019 @08:48PM (#20359070)
nope, it's meant for micro-service architecture where you have a lot of different api end-points spread across different servers, databases, technologies, shards, etc. So you need to get user profile from one side, and a list of news from the other, and then cross-reference that with a list of friends from the 3rd source, and then you need to combine all that together into something usable in the client. GraphQL is a way to define how to merge those datasets, without manually coding each step of taking field X from feed A and list Y from feed B and indexing them by Z. Beside obviously solving problems for huge players like FB, it also helps with common situations when UI design is being constantly changed along the way and all of the sudden front-end team needs APIs to return shitload of new relations that were not in initial specs. In most startups that I've worked on APIs 99% of my time was reworking queries to include more data because designers and UX people had changed their mind. GraphQL makes this fairly painless as long as you have a well defined set of basic APIs. Then later when the design gets more stable you can locate the bottlenecks and rework them into more complex, but faster API calls.
Re:Migrating to GraphQL: A Practical Assessment by strken on Thursday July 04, 2019 @09:37PM (#20359274)
Not sure I understand why in-memory joins are wrong by default, especially in a large system with more than one data store.

Let's say you call UserService::batchGetUsers(userIds) to get a list of users from a service backed by a MySQL DB, call WidgetService::widgetsForUser(userId) to get a list of a user's widgets from a separate service backed by a Redis cache and another MySQL DB, and return them. What's the problem here? Lack of transactions? Unnecessary fields sent down the wire? Something else?

Re:Migrating to GraphQL: A Practical Assessment by emerongi on Friday July 05, 2019 @02:35AM (#20360323)
There is no problem, the same way GraphQL does not automatically allow arbitrary queries.

The parent author holds some very stubborn beliefs about how systems are built (his/her way is the correct way!), which is great for discussion, but probably not the best example on how to actually build big systems.

Re:Migrating to GraphQL: A Practical Assessment by jayd16 on Friday July 05, 2019 @01:20AM (#20360029)
> the sever defines what queries are available

>avoid having to write a custom endpoint for every single REST query

So what are you saving, really? Could you better implement GraphQL type functionality as a client side wrapper for traditional REST apis? Then you could keep the traditional tooling as well as simple query join semantics for client devs.

Re:Migrating to GraphQL: A Practical Assessment by PunksATawnyFill on Friday July 05, 2019 @02:52AM (#20360395)
Oh really? Because I’ve yet to see anyone explain how joins can be accomplished with GraphQL.