Visitar URL original
feat: add `optionsApi` option to skip the Options API provider by onmax · Pull Request #678 · nuxt-modules/apollo · GitHub
Skip to content

feat: add optionsApi option to skip the Options API provider - #678

Open
onmax wants to merge 2 commits into
nuxt-modules:v5from
onmax:perf/options-api-opt-out
Open

onmax wants to merge 2 commits into
nuxt-modules:v5from
onmax:perf/options-api-opt-out

Conversation

@onmax

@onmax onmax commented Oct 30, 2026 •

Copy link
Copy Markdown

🔗 Linked issue

None. Related to #575, which added Options API support.

❓ 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

The plugin always installs @vue/apollo-option. Its global mixin runs on every component, even in apps that only use composables. In SSR its serverPrefetch hook makes every component render async, so useId() values get longer at each level:

reka-tabs-v-0-0-0-0-0-0-0-0-0-0-0-0-0-1-0-0-0-0-0-0-8-0-trigger-0   (now)
reka-tabs-v-0-19-1-trigger-0                                       (optionsApi: false)

This adds apollo.optionsApi. It defaults to true, so nothing changes for existing apps. Set it to false to skip the provider. Composables keep working. The apollo component option needs the provider, and without it this.$apollo is the plain { clients, defaultClient } object from useNuxtApp().$apollo, so this.$apollo.query() is gone.

I tried it on a Nuxt UI app with no Options API queries. With false, the HTML stays the same apart from the ids, pages are 2 to 5% smaller, and the server no longer runs @vue/apollo-option. CPU was mixed. One page got 13% faster, and a page with a big table got 6% slower, which I can't explain yet.

v5 has no tests, so the second commit adds vitest and @nuxt/test-utils, with tests for both settings and for the composables with optionsApi: false. Run pnpm dev:prepare, then pnpm test. I can drop that commit if you'd rather not have it.

@netlify

netlify Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

👷 Deploy request for apollo-module pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit f3642e7

@onmax
onmax force-pushed the perf/options-api-opt-out branch from 612de44 to f3642e7 Compare October 30, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant