apollo icon indicating copy to clipboard operation
apollo copied to clipboard

fix: composable loosing contexts during tests

Open HaNdTriX opened this issue 11 months ago โ€ข 1 comments
trafficstars

๐Ÿ”— Linked issue

  • https://github.com/nuxt-modules/apollo/issues/638

โ“ Type of change

  • [ ] ๐Ÿ“– Documentation (updates to the documentation or readme)
  • [x] ๐Ÿž 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.

HaNdTriX avatar Dec 15 '24 19:12 HaNdTriX

Deploy Preview for apollo-module canceled.

Name Link
Latest commit a9ebeb3a74e90ea38d95ea2955d30c6d038ea477
Latest deploy log https://app.netlify.com/sites/apollo-module/deploys/675f2b1ca816a80008a0c54c

netlify[bot] avatar Dec 15 '24 19:12 netlify[bot]