Meteor, Apollo, and the @live directive

@moberegger, thanks for starting this thread. It’s good to have a centralised place to talk about this specific topic. I’m very interested in this myself and done some research on the current state of the @live directive. Although I think Meteor is up for the task, there is a lot of work to be done in other areas.

Keeping close to the mainstream libraries

There is always a way to implement it ourselves, but personally, I would like to see support build in standard libs. The example repository using Meteor with RxJS is a great initiative. But if we want people to actually start using it, we want to keep close to the spec and mainstream libs. I’ll go into more detail about this later.

So what needs to be done to support @live for everyone?

  • Apollo Client doesn’t support @live yet
  • graphqljs doesn’t support multiple results from a query yet (Observables)

See this thread for the current state of support in Apollo Client 2:

This is on the roadmap for the Apollo Server:
https://github.com/apollographql/apollo-server/blob/master/ROADMAP.md#support-for-defer-live-and-stream

  • Talking about the need for Observables in graphqljs.

Currently working example of Meteor and @live

I also think this is the example repo he talks about:

There are some issues though:

  • Doesn’t work with Apollo 2. See for example this issue.
  • Doesn’t seem to be aware of the proposed patch syntax. ({ path: [ 'author', 'posts', 0 ], data: { title: 'Hello', views: 10 } })
  • It uses RxJS (meteor-rxjs), which is very good lib, but we might get away with using plain Observables.
  • Uses own GraphQL-RxJS, which is nice, but not standard.

Other interesting issues/discussions

Lee Byron, one of the authors of GraphQL, is saying you don’t need observables, but doesn’t give a hint about an alternative:

Grapher

Grapher is also a great peace of software. @diaconutheodor did a great job here and explains some of the pain points of GraphQL in this post:

I believe though, also after the video you shared, that these issues will get addressed in the future and with help from the community, we can make GraphQL (almost) as easy to setup as Meteor, including support for @live queries. In the meantime, for people who can’t wait for that, Grapher is a nice alternative. But again, not as widely supported as GraphQL.

Next steps

I believe the focus should be on getting @live support into Apollo and GraphQL itself and work from there. Connecting Meteor afterwards, probably using Observables, should be a walk in the park (which it never turns out to be, but let’s stay positive here :wink: ).

1 Like