News for hackers. Stuff that matters.
Re:GQless: A GraphQL client built for rapid iteration by a_humean on Wednesday June 02, 2021 @09:53AM (#27368680)
How do you deal with error handling? I don't see anything in the docs about error handling.

How do you deal with union types? The docs seem completely scant on that.

Otherwise very interesting approach.

Re:GQless: A GraphQL client built for rapid iteration by occz on Wednesday June 02, 2021 @10:49AM (#27369328)
Handling loading states also seems to be a little bit on the anemic side, but I didn't investigate too deeply.
Re:GQless: A GraphQL client built for rapid iteration by merrywhether on Wednesday June 02, 2021 @02:30PM (#27372243)
The primary example code relies on Suspense, meaning that loading behavior will be handled by a parent/ancestor <Suspense /> component and not in the component itself. I think they default to showing this pattern since it is the “future” of React. There is an alternate version of the API where you can get a loading boolean for imperative control.
Re:GQless: A GraphQL client built for rapid iteration by a_humean on Wednesday June 02, 2021 @11:31AM (#27369851)
Yes, it doesn't really distinguish between loading vs null values in any of the examples.

My guess is its going to be something like `undefined` means loading and `null` means null.

Re:GQless: A GraphQL client built for rapid iteration by nwienert on Wednesday June 02, 2021 @01:24PM (#27371438)
There’s a different hook you can use that returns an error state.
Re:GQless: A GraphQL client built for rapid iteration by merrywhether on Wednesday June 02, 2021 @02:35PM (#27372297)
The useQuery hook’s opts have an onError property that accepts a callback.

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.

Re:GQless: A GraphQL client built for rapid iteration by ericlewis on Tuesday June 01, 2021 @03:07PM (#27359704)
So instead of having a schema a schema is created from the React usage? I am not entirely sure what this does.
Re:GQless: A GraphQL client built for rapid iteration by linkdd on Tuesday June 01, 2021 @04:36PM (#27360941)
If I understand correctly, it's more like the query (not the schema) is generated from the expected result.

So your application does not need to "talk in GraphQL".

Re:GQless: A GraphQL client built for rapid iteration by millerm on Tuesday June 01, 2021 @04:51PM (#27361109)
The main advantage is that the query is resolved at runtime. It only queries for exactly what your component needs. No over-querying. No sharing queries across components, which is a huge mistake people make.
Re:GQless: A GraphQL client built for rapid iteration by andrewingram on Wednesday June 02, 2021 @09:37AM (#27368524)
I'd say you're broadly right, the key idea is that your client code has a facade over the fact that you're using GraphQL, so it looks cleaner -- it's "just JavaScript". Whether this is an advantage or not is largely down to preference.

The "Why" section in the docs is a pretty good summary:

https://gqless.com/intro#why

"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.

Re:GQless: A GraphQL client built for rapid iteration by golergka on Wednesday June 02, 2021 @09:33AM (#27368483)
> query is resolved at runtime

Does it mean that we get errors at runtime and not build time, too?

Re:GQless: A GraphQL client built for rapid iteration by SketchySeaBeast on Wednesday June 02, 2021 @09:50AM (#27368655)
Have you found a way to get build errors with GraphQL queries? I only ever get them during runtime when the request is made, I assume because that's the point at which the back-end and front-end disagree on what you're requesting.
Re:GQless: A GraphQL client built for rapid iteration by potatoz2 on Wednesday June 02, 2021 @11:18AM (#27369699)
If you generate types from your GraphQL queries, they are validated against the schema at that time (so you'd get schema errors then, of course there can still be network errors, server errors or user/semantic errors at runtime)
Re:GQless: A GraphQL client built for rapid iteration by nawgz on Wednesday June 02, 2021 @01:26PM (#27371458)
Using Typescript,GraphQL-codegen, and Hasura, I can build correct-by-construction React apps. GraphQL-codegen & Hasura introspect the DB to type the query result, and typescript confirms my JS is not accessing any of those fields illegally.

It’s pretty killer to open GraphiQL, write a new query, drop it into a graphql file in my repo, rerun the codegen, and be able to have type safe operations on the queried data.

Also makes me completely unsure why anyone would want what the OP is but that’s ok

Re:GQless: A GraphQL client built for rapid iteration by atom_arranger on Wednesday June 02, 2021 @06:59PM (#27375070)
This solution seems to work like this:

  - Generate type safe client based on your schema.
  - Access GraphQL properties as if they were just JS object properties.
So in this solution the codegen step comes before writing a query.

You get the same advantages pretty much, and you have less likelihood of querying for unused data.

Re:GQless: A GraphQL client built for rapid iteration by revskill on Wednesday June 02, 2021 @09:51AM (#27368666)
This part is confusing to me.

I prefer this will validate our component for correct schema usage at build time.

Re:GQless: A GraphQL client built for rapid iteration by nwienert on Wednesday June 02, 2021 @10:06AM (#27368832)
It fully typed, so you get errors at build time.
Re:GQless: A GraphQL client built for rapid iteration by coding123 on Wednesday June 02, 2021 @11:44AM (#27370028)
I think the part that's throwing people off (including me) is if I'm looking at that main example, how do I get type completion on this line:

    Hello {query.me.name}!
query dot me dot name should all have type completion. And in most TS "frameworks" you have some way to type hint this all out. us TS folk are not seeing the type hints in the example. Maybe it works in VSCode like that, but totally confused how it does.

Believe me, I'm super interested in this project and it would save a ton of time if it's doing what some of us are hoping :)

Re:GQless: A GraphQL client built for rapid iteration by nwienert on Wednesday June 02, 2021 @01:26PM (#27371457)
It does autocomplete with types on that line, and yes, it’s really that cool.

Disclosure: I funded the development of version 2, and have written a large app using it. I am very happy with it, and believe it’s the best data fetching solution around.

Re:GQless: A GraphQL client built for rapid iteration by atom_arranger on Wednesday June 02, 2021 @07:01PM (#27375084)
The client is generated from the schema, so “query.me.name” is fully typed.
Re:GQless: A GraphQL client built for rapid iteration by atom_arranger on Tuesday June 01, 2021 @08:43PM (#27363421)
This looks like it has a shot at being a better developer experience than Relay while still encouraging the use of nested queries (unlike clients like Apollo and urql). Nice.
Re:GQless: A GraphQL client built for rapid iteration by zwily on Wednesday June 02, 2021 @09:46AM (#27368603)
How do Apollo and urql discourage using nested queries?
Re:GQless: A GraphQL client built for rapid iteration by atom_arranger on Wednesday June 02, 2021 @07:09PM (#27375150)
You can’t pass along the result (not exactly but that’s how it looks) of a query to a component and query more things on it.

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).

Re:GQless: A GraphQL client built for rapid iteration by felipellrocha on Wednesday June 02, 2021 @11:15AM (#27369673)
This is great except for one thing. I like types generates during static time, not runtime. Anyway we could verify types at that time?
Re:GQless: A GraphQL client built for rapid iteration by nwienert on Wednesday June 02, 2021 @02:29PM (#27372232)
It generates types via CLI statically up front, all queries are then fully typed, only the final request is generated at runtime which means you never fetch anything except what you need.
Re:GQless: A GraphQL client built for rapid iteration by ingas on Friday June 11, 2021 @12:22AM (#27469260)
So it's a generation of graphql on-fly, right?

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.

Re:GQless: A GraphQL client built for rapid iteration by coding123 on Wednesday June 02, 2021 @11:36AM (#27369906)
One of our requirements is to disable schema downloading in production in apollo server. (We can have it enabled in dev/local). Can this work if that is disabled? (Yes we know this is silly but our auditor caught it)
Re:GQless: A GraphQL client built for rapid iteration by harg on Wednesday June 02, 2021 @12:08PM (#27370359)
From my understanding this should work as the schema is introspected ahead of time. This gives all the type information needed for the `useQuery` hook to work properly. Just the queries themselves are generated at runtime; there shouldn't be any need to introspect the schema then.

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.

Re:GQless: A GraphQL client built for rapid iteration by wereHamster on Wednesday June 02, 2021 @11:58AM (#27370215)
What's the reasoning behind not allowing it?
Re:GQless: A GraphQL client built for rapid iteration by nguyenkien on Wednesday June 02, 2021 @12:06PM (#27370314)
Hiding details
Re:GQless: A GraphQL client built for rapid iteration by tompazourek on Wednesday June 02, 2021 @01:39PM (#27371656)
It reminds me a little bit of QBE (Query by example), but instead of saying what data you want, you say what schema you want.
Re:GQless: A GraphQL client built for rapid iteration by beaunative on Wednesday June 02, 2021 @01:39PM (#27371658)
This is amazing concept. It literally transforms remote api into local resource with the aid of graphql.
Re:GQless: A GraphQL client built for rapid iteration by k__ on Wednesday June 02, 2021 @09:44AM (#27368587)
I really like these event-loop/proxy-object tricks.

It always feels like magic.

Re:GQless: A GraphQL client built for rapid iteration by outerlook on Wednesday June 02, 2021 @10:55AM (#27369415)
the greatest value on it for me is the scalability of relay, without the boilerplate.

Colocating data requirements next to where it is using it without writing it two times is awesome!

Re:GQless: A GraphQL client built for rapid iteration by millerm on Tuesday June 01, 2021 @04:50PM (#27361088)
I’m very interested in this! Thanks for posting!
Re:GQless: A GraphQL client built for rapid iteration by elitan on Wednesday June 02, 2021 @12:48PM (#27370914)
Wow, that's cool!
Re:GQless: A GraphQL client built for rapid iteration by hrpnk on Wednesday June 02, 2021 @01:46PM (#27371741)
Cool for prototyping, but likely difficult to maintain over a longer period of time.

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.

Re:GQless: A GraphQL client built for rapid iteration by nwienert on Wednesday June 02, 2021 @02:30PM (#27372240)
There’s no reason all of this isn’t supported as well if not better in GQless than any other client.

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.

Re:GQless: A GraphQL client built for rapid iteration by bionhoward on Wednesday June 02, 2021 @09:19AM (#27368334)
ES6 Proxy is awesome