DEV Community

Jan Dvorak
Jan Dvorak

Posted on

3 1

Apollo integration with MeteorJS v4.2 release and looking to v5

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')
}
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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 ❤️.

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay