103 points · by rgbrgb · 5y ago · 39 comments
How do you deal with union types? The docs seem completely scant on that.
Otherwise very interesting approach.
I also don’t see anything about union types. That definitely seems like the hardest thing to reverse construct based on usage, since the underlying proxy wouldn’t know what you’re doing with __typename.
So your application does not need to "talk in GraphQL".
The "Why" section in the docs is a pretty good summary:
"I wanted a GraphQL client that lets you forget you're using GraphQL, whilst tackling some issues shared across all existing GraphQL clients"
The fact that it's resolved at runtime isn't necessarily an advantage, it locks you out of some performance and security patterns. I believe GQLess is investigating support for static extraction of queries at build time.
It's an interesting API, I'm not entirely sold on the idea of disguising the fact that you're using GraphQL though.
Does it mean that we get errors at runtime and not build time, too?
An example might be something like, you have a page showing a user, and you have a ProfilePicture component with certain data requirements (e.g. get picture at 100X100). It would be nice if you could pass down the user and have the ProfilePicture component query the data it needs, with this being merged into the parent request.
In Relay this kind of thing can be done with useFragment.
In this solution it seems you could just pass the user.
Apollo/urql don’t support this pattern, everything must be in one top level query, or multiple queries (bad perf).
I conclude that it will be incompatible with hasura Allow-list (or lead to explosion of Allow-list for all possible combinations which is impossible in practice)
So it could look nice but makes unusable in case you rely on Allow-list for security.
It could be good for prototyping.
Where this might have an issue is with persisted queries. But then you'd need some sort of client/server build tooling to keep them in sync.
It always feels like magic.
Colocating data requirements next to where it is using it without writing it two times is awesome!
Just like with an ORM on top of a DB, if one needs to to performance optimization or support parallel app versions and ensure backwards-compatibility of queries, the actual queries are useful if not essential to know and manage.
You can hoist the query logic if you need to ensure it stays static for some reason.
I’ve built a very large app with this and am perfectly happy with the model, it has many upsides vs having to manually link strings into views, like never overfetching and having fully typed queries without any plugins.