Hi, I’ve been hunting and searching high and low to get a Meteor/Apollo/React integration working with subscriptions, but I’ve not been able to get any proper working version of it.
The v2 docs used to have a page for the Meteor integration but it is non-existent in the v3 docs.
I managed to get close once, with the following setup:
Client:
const client = new ApolloClient({
link: new DDPLink(),
cache: new InMemoryCache()
})
const ApolloApp = () => (
<BrowserRouter>
<ApolloProvider client={client}>
<App />
</ApolloProvider>
</BrowserRouter>
)
Meteor.startup(() => {
render(<ApolloApp />, document.getElementById("app"))
})
Server:
const schema = makeExecutableSchema({
typeDefs,
resolvers,
})
setup({
schema
})
This was done with the swydo:ddp-apollo package. This uses Meteor’s DDP link instead of creating a new WebSocket connection.
But there are a few limitations:
- I cannot use Graphiql if I do this. The Graphiql tab in Apollo Client DevTools is blank as well (even without using this code for the client/server). If I use my old code which does not support subscriptions, Graphiql works fine but the Apollo Client DevTools extension is still bugged. I’ve filed a bug report on this front, but this is still a limitation I’m currently facing.
- I observed the Network tab and I noticed that every query, mutation and subscription uses a WebSocket link. Isn’t it inefficient to have everything go through a WebSocket link? That means that every single user connected to my website will have a perpetually open WebSocket link, even when I only need it for subscriptions. Queries and mutations go through the same link. Will that scale correctly?
Appreciate any help, thank you.
EDIT: Not sure why this was flagged as spam?