Hacker News new | ask | show | jobs
by mej10 2886 days ago
We have, so far, only made a GraphQL endpoint for internal use. It has been awesome for quickly finding things in a medium-complexity database schema (30 or so tables, bunch of different relationships). It has become my preferred way to quickly find things in the database.

That being said, there are cases where a join between ad hoc subqueries is the best way, and GraphQL doesn't really offer a way to do that (though I don't see why it wouldn't be possible). E.g. arbitrarily combining two GraphQL queries that return lists where some field in one is equal to some field in another.

But in terms of replacing REST, where you have to do all of that anyway, it is far and away the better option (for ad hoc querying, at least).

1 comments

> a join between ad hoc subqueries is the best way, and GraphQL doesn't really offer a way to do that

I think you're supposed to create a "virtual" field on the left-hand object that represents a collection of the right-hand type of objects. The field can be parameterized if your join needs extra information. If you want pagination, the virtual field returns an intermediary object describing the cursor (sort order, offset).