Live data from Hacker News

GraphQL Live Queries with live directive

grafbase.com

11–12 of 12 posts

Re: GraphQL Live Queries with live directive

#11
post #3

Huh, I've been thinking about a very similar service that does not require a dependency on GraphQL — https://poll2hook.com/ You can define a query on any API, be it GraphQL or REST, and a jq query to extract events, and you are good to go. I wonder if this @live directive is implemented with polling?

You could also implement live queries using polling and the E-Tag, If-None-Match header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If...).

We experimented with something similar on a customer project where having a long-lived HTTP connection was not possible.

Re: GraphQL Live Queries with live directive

#12
post #4

I love GraphQL, it makes generating types for any language very easy, with one schema, and you don't have to worry about the shape of the response on either the server or the client due to such types. If you don't need multiple clients and are using TypeScript, you could use trpc though (and with Rust I also know of rspc). This article is interesting, however it seems `@live` isn't part of the official specification.…

I'm still not sure about benefit of GraphQL over welled designed Restful API.

We chose GraphQL at Grafbase for a few reasons:

- The client can ask for the data it needs, which also improves performance by reducing bandwidth

- Aggregating data from multiple data sources with a single request

- Widely adopted and loved by frontend and mobile developers

Post reply on HN