Apollo integration with MeteorJS v4.2 release and looking to v5
Jan Dvorak
Posted on April 26, 2023
April 19th saw a a new release of Apollo GraphQL integration for MeteorJS. This MeteorJS package integrates Meteor's account system with Apollo and gives you access to the currently logged in user in the GraphQL context.
In your resolver that would look like this:
upcomingEventsNum: async (
{ _id, type, ownerId }: Blog,
_: unknown,
{ user }: ResolverContext
) => {
if (!user) throw new Error('notLoggedIn')
}
The v4.2.0 is a small update that saw the update to the latest Apollo client (v3.7.12) and update of tests to run on GitHub.
This brings us to talk about v5. Since the Apollo client is included in the MeteorJS package it makes the package quiet large and in constant need of updates when a new Apollo package is released. Since in most cases Apollo client NPM package (@apollo/client
) gets installed regardless in a MeteorJS app when Apollo is used, the inclusion in the apollo
package becomes redundant and is duplication of what is already included by NPM.
This becomes an issue when you try to slim down your bundle size as you suddenly have two instances of @apollo/client
in your bundle.
Following the example of jQuery
in BlazeJS (where jQuery was removed from Blaze and you have to install in as a peer dependency) the proposal now is to remove Apollo client from the apollo
MeteorJS package and allow you to install and manage the Apollo client NPM package independently as a peer dependency.
This slims down your client bundle by removing the duplicate Apollo client and allows you to keep up with the most recent version of Apollo client, at least until changes demand changes in the Meteor's Apollo package.
This proposal is expected to be merged and released as version 5 of the Meteor's Apollo package. Feel free to provide feedback on the PR for v5.
If you want to prepare for this major package upgrade, you just need to add Apollo client package to your application (though chances are you already have it).
meteor npm i --save @apollo/client
Then you just need to wait for the release of v5 and upgrade to it when the time comes and you are done!
If you like my work, please support me on GitHub Sponsors ❤️.
Posted on April 26, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.