News for hackers. Stuff that matters.
Re:Graphql-Up: CLI to create a ready-to-use GraphQL API by Exuma on Tuesday March 14, 2017 @09:05PM (#13873028)
I looked at GraphQL..... can someone please explain how extensive join queries are done?

Literally almost every app I ever write, even the simple ones, offload tons of work to the database for joins between a half dozen tables.

I have yet to see a sane answer on how this is possible with GraphQL? How am I supposed to think about performance ... and not just having something overly simple/basic like HERES MAH BLOG... HERES DA COMMENTS!!!!!!

Re:Graphql-Up: CLI to create a ready-to-use GraphQL API by jlouis on Tuesday March 14, 2017 @09:18PM (#13873061)
Squint your eyes a lot!

A GraphQL query is just a query on some objects having some fields. You can tie any function to a field. In particular, you can have each field be a function which executes SQL code. And that code is free to JOIN as it wants.

Squint your eyes some more: how do you do it in a RESTful interface? It is the same idea.

GraphQL really excels, however, in that it is not tied to SQL. You can have part of the query be from one source, and other parts be from other sources.

Re:Graphql-Up: CLI to create a ready-to-use GraphQL API by Horusiath on Wednesday March 15, 2017 @04:15AM (#13874580)
It depends on the actual implementation of the server side, that you're using. From what I remember (this may have changed):

- Ruby implementation can dig into Active Record to perform batching of the queries, that normally would be executed in parallel.

- JavaScript implementation may use DataLoader library to support the same batching behavior for basically any async (promise-based) operation. See this presentation, it shows how the issue look like and how Data Loader helps to solve it: https://www.youtube.com/watch?v=c35bj1AT3X8&t=15m42s

- Python and Elixir implementations can make use of information about query subsegments, so you can prefetch necessary data.

- F# implementation works in similar way to Elixir but it's not limited to analyse GraphQL query fragments, but can also perform live analysis of the user-defined resolve functions code to determine a tree of used F# objects and properties instead. This allow to diverge GraphQL domain model from the underlying database model.

- A lot of other libraries are dedicated to particular database or query language and map GraphQL schema directly onto database model, so GQL query is translated directly into underlying database query model (including joins).

Re:Graphql-Up: CLI to create a ready-to-use GraphQL API by jahewson on Wednesday March 15, 2017 @01:13AM (#13873970)
GraphQL is not a query language for your database, it's more like a query language for your REST API.

So asking how to do a join in GraphQL is like asking how to do a join in REST. It's not a well-formed question.

The good news is that the sever can expose absolutely anything as a GraphQL query. They're just arbitrary entry-points into the schema. Think of it as like calling a stored procedure. The procedure is an opaque thing as far as the caller is concerned.

Re:Graphql-Up: CLI to create a ready-to-use GraphQL API by ruslan_talpa on Wednesday March 15, 2017 @04:00AM (#13874534)
You are dismissing a valid question and incidentally this is the question that exposes a problem of the graphql-js implementation (specifically the execution module) when the data source is a database (which 90% of the time it is), though it's not a problem of the GraphQL . Of course he can not "well-forme" it since he is just looking into GraphQL. What he is looking for actually is this https://github.com/stems/join-monster but it's not without it's problems.

PS: My comment does not mean the reference implementation is bad, it's just that it's a reference and good in a lot of cases but not in all. It does not mean you have to use every part of it, you can write your own execution module.

Re:Graphql-Up: CLI to create a ready-to-use GraphQL API by ruslan_talpa on Tuesday March 14, 2017 @09:44PM (#13873149)
Look at PostgREST, then look at what &select parameter does, you'll see a mini GraphQL query there. Every request generates a single query. Then know that it's possible to have PostgREST execute GraphQL queries :)