Meteor1.7 + Apollo2 (Server/Client) integration


#1

I keep reading posts here where they said Apollo can be added to METEOR… is there a guide to and examples for adding Apollo (Server/Client) to Meteor WITHOUT using a 3rd party, non-MDG libraries?

I’d like to use only the MDG supplied libs, something like:

meteor npm install --save apollo-client apollo-server

Then quickly get started with examples using both these libs, something like?

// Meteor/Apollo Client side-by-side
const client = new ApolloClient(…);
// call Apollo mutations/queries
// subscribe to publicstions
// call Meteor methods
// us Meteor.userId()

// Meteor/Apollo Server side-by-side
const server = new ApolloServer(…);
// create Apollo mutations/queries/resolvers
// publish documents
// create Meteor methods
// use Meteor.userId()


#2

Have you seen the Meteor Apollo starter kit. Not sure if it’s what you’re looking for (and it may be outdated now), but the code is easy to follow.


#3

Extremely outdated! Don’t waste your time on it.

Most other starter kits, tutorials, and a lot of the documentation and blog posts out there are also outdated and hence would also be time-wasting.

There is some discussion here: https://github.com/apollographql/meteor-starter-kit/issues/54


#4

I have some things working with the latest concepts and syntax (data sources, MeteorAccountsLink, etc.) with SQLite database, but have been having trouble using Apollo Server’s built-in subscription server. I created an issue here: https://github.com/apollographql/apollo-server/issues/1537.

I like ddp-apollo vbery much but that has become outdated with the new Apollo Server 2 and the official meteor-integration 3.0.0.

It has been frustrating, but once the dust settles it’s going to be amazing.


#5

I wrote this write-up a while ago when I was first trying to figure out Apollo. It’s specific to Meteor and includes subscription support. I may need to update some of the package versions (what used to be in beta is now out).

How to get Apollo 2.0 working with GraphQL + subscriptions


#6

Thanks everyone so far…

@michaelcbrook do we still need all thouse packages installed from your Medium post?

The MDG Meteor+Apollo integration docs suggests only:

meteor add apollo
meteor npm install --save apollo-client graphql-server-express express graphql graphql-tools body-parser

Have you thought about doing an update on that post (since it will be the only one online it seems)?

NOTE: Apparently MDG recommends swydo:ddp-apollo package for Meteor integration? I like the idea of running things side by side, not integrating Apollo into the DDP socket. When I want Meteor, it’s there, when I want Apollo, I’ll have it.


#7

I agree, and having them separate makes scaling a possibility. You can take the apollo instance (which runs on Express.js) and spin that into it’s own node swarm, and leave Meteor on its own server. Or you can even replace the apollo server with another apollo server altogether. It’s pretty flexible, and it’s great that they can all run on the same service from the start.

BTW, my starter has an apollo branch (which I updated as a reference to help out the Vulcan.js project) that you can check out for a fairly minimal set of requirements.


#8

Thanks @captainn, I’ll check out and star the repo!


#9

I had a quick look and can see that it’s outdated now. e.g. there is now no need to create a SubscriptionServer. Apollo Server does it for you. There is a subscriptions option in the ApolloServer constructor.


#10

MDG recommends swydo:ddp-apollo

I liked that one very much but now that is outdated too after Apollo Server 2.


#11

@tab00 I actually don’t like that DDP version of Apollo very much. I just want to use Apollo side by side with Meteor without all the other “stuff” from other libs.


#12

I didn’t find a whole lot of those packages to be optional. I was able to get rid of a lot of the betas, but the newest available version of apollo (3.0) seems to actually not be compatible with Meteor 1.7 I believe. I did have to downgrade apollo and one other package down to 2.0 to keep it working, which is still one version above what I was using when I wrote the post (1.0). I can go back and check exactly which package versions I’m using.

If you’re content using DDP with Apollo, then by all means. It really depends on your use case. It wasn’t ideal for mine.


#13

Thanks for that. I’d actually like a Apollo Server/Client 2.* with a Meteor 1.7.* sync up. I didn’t actually even know Apollo 3.0 was a thing at this point.

No, I’m not interested in DDP-Apollo. I’d like to use them side-by-side without that level of integration. :slight_smile:


#14

Can you elaborate?

Here is a working bare-bones implementation of the latest (3.0) meteor-integration:


#15

That example uses createApolloClient and createApolloServer which are now deprecated.


#16

Technically, you can now use the in-built Apollo Server 2 subscriptions with Meteor’s WebApp HTTP server.


#17

I’m sure you’re right, but I have to get the basics down before getting fancy with it. :slight_smile:

If I start out side by side, then I can start to make out where it makes sense to loosely “join” the two. But I really DON’T want Apollo to piggy back on the DDP socket for some reason. :smiley:


#18

There’s no DDP in the “new ways” of Meteor and Apollo integration.

I posted my code showing use of Meteor’s WebApp with ApolloServer in this issue: https://github.com/apollographql/apollo-server/issues/1537


#19

Right. I get that. I only brought up DDP-Apollo because of this from MDG recently (~15 days ago):

I can’t wait until they get the official Apollo + Meteor integration docs out the door :slight_smile:


#20

Thanks for the link…

Will you create a reference repo so I can try to recreate your issue?