fix: composable loosing contexts during tests by HaNdTriX ยท Pull Request #639 ยท nuxt-modules/apollo

๐Ÿ”— Linked issue

โ“ Type of change

  • ๐Ÿ“– Documentation (updates to the documentation or readme)
  • ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • ๐Ÿ‘Œ Enhancement (improving an existing functionality)
  • โœจ New feature (a non-breaking change that adds functionality)
  • ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries)
  • โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change)

๐Ÿ“š Description

This PR removes @vue/apollo-composable from nuxt.options.build.transpile.

Adding @vue/apollo-composable to nuxt.options.build.transpile causes all kinds of bugs since the module might be imported & executed twice.

  1. Via nuxt.options.build.transpile (here)
  2. Via plugin import (here)

This causes some composables (e.g. useQuery or useMutation) to loose context (currentApolloClients) in specific scenarios.

One such scenario is running vitest & @nuxt/test-utils test with useQuery or useMutation:

Apollo client with id default not found. Use an app.runWithContext() or provideApolloClient() if you are outside of a component setup.