Registry / web-framework / vue-cli-plugin-apollo

vue-cli-plugin-apollo

JSON →
library0.22.2jsnpmunverified

vue-cli-plugin-apollo is a Vue CLI 3.x plugin that streamlines the integration of Apollo Client and GraphQL into Vue.js projects. It automates much of the boilerplate setup, including configuring Apollo Client with features like WebSockets, file uploads, and client-side state management (via apollo-link-state). The plugin also offers an optional, customizable GraphQL server based on Apollo Server, complete with automatic mocking, Apollo Engine support, and an integrated GraphQL Playground in the CLI UI. It provides commands for schema generation and publishing. The current stable version is 0.22.2, with an active but irregular release cadence focused on maintenance, bug fixes, and updates to underlying Apollo libraries. Its key differentiator is the rapid, opinionated setup it provides for full-stack GraphQL development with Vue, significantly reducing manual configuration.

npm install vue-cli-plugin-apollo
INSTALL
IMPORT
SIG · VUE-CLI-PLUGIN-APO
V
vue-cli-plugin-apollo
web-frameworkjavascriptv0.22.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

gql
import gql from 'graphql-tag';
import { gql } from '@apollo/client';
The `gql` tagged template literal for defining GraphQL queries, mutations, and subscriptions is typically imported from `graphql-tag`, which is the recommended method for passing queries to Apollo Client.
useQuery
import { useQuery } from '@vue/apollo-composable';
import { useQuery } from 'vue-apollo';
For Vue 3 and the Composition API, `useQuery` (and `useMutation`, `useSubscription`) are provided by `@vue/apollo-composable`. While `vue-apollo` is the underlying integration, the composables offer a reactive, hook-like interface.
ApolloProvider
import { ApolloProvider } from '@vue/apollo-composable';
import { ApolloProvider } from 'vue-apollo';
When using the Composition API, `ApolloProvider` from `@vue/apollo-composable` is used to provide the Apollo Client instance to all child components.

Demonstrates `vue add vue-cli-plugin-apollo` followed by basic Apollo Client setup and a Vue Composition API component fetching data using `useQuery` and `gql`.

import { createApp } from 'vue'; import App from './App.vue'; import router from './router'; import { ApolloClient, InMemoryCache, HttpLink } from '@apollo/client/core'; import { provideApolloClient } from '@vue/apollo-composable'; // This setup is typically handled by the plugin's generator, // but here's a conceptual example for main.ts/js. // The plugin usually sets up an httpLink and InMemoryCache for you. const httpLink = new HttpLink({ uri: process.env.VUE_APP_GRAPHQL_HTTP || 'http://localhost:4000/graphql', headers: { // Ensure Authorization header is capitalized for v0.22.2+ Authorization: process.env.VUE_APP_GRAPHQL_TOKEN ? `Bearer ${process.env.VUE_APP_GRAPHQL_TOKEN}` : '', }, }); const apolloClient = new ApolloClient({ link: httpLink, cache: new InMemoryCache(), }); const app = createApp(App); // Provide the Apollo Client to the entire app app.setup = () => { provideApolloClient(apolloClient); }; app.use(router); app.mount('#app'); /* Example Vue Component using the plugin-provided Apollo setup */ /* <template> <div> <h1>Characters</h1> <p v-if="loading">Loading...</p> <p v-if="error">Error: {{ error.message }}</p> <ul v-if="characters"> <li v-for="char in characters" :key="char.id">{{ char.name }}</li> </ul> </div> </template> <script setup lang="ts"> import { useQuery } from '@vue/apollo-composable'; import gql from 'graphql-tag'; import { computed } from 'vue'; interface Character { id: string; name: string; } interface AllCharactersResponse { characters: Character[]; } const ALL_CHARACTERS_QUERY = gql` query AllCharacters { characters { id name } } `; const { result, loading, error } = useQuery<AllCharactersResponse>(ALL_CHARACTERS_QUERY); const characters = computed(() => result.value?.characters ?? []); </script> */
Debug
Known issues
breakingThe 'Authorization' header name now requires capitalization ('Authorization' instead of 'authorization') due to a breaking change in v0.22.2. Applications with hardcoded lowercase headers will fail authentication.
fix
Update any custom Apollo Link configurations or `getAuth` functions to ensure the 'Authorization' header uses correct capitalization.
affects: >=0.22.2
breakingVersion 0.19.0 introduced major version updates to Apollo Server (to 2.3.x) and Apollo Upload Client (to 10.x). These updates may require changes to server-side GraphQL implementations and client-side file upload configurations.
fix
Consult the Apollo Server and Apollo Upload Client changelogs for specific migration instructions for versions 2.3.x and 10.x respectively. Review server-side schema definitions, resolvers, and file upload handling.
affects: >=0.19.0
breakingA potential breaking change in v0.20.0 modified `vue-loader`'s `transpileOptions` to support the `gql` tag inside component templates. This might affect custom `vue-loader` configurations.
fix
Review `vue.config.js` for any custom `vue-loader` configurations that might conflict with the plugin's changes. Ensure proper handling of GraphQL tagged template literals within Vue single-file components.
affects: >=0.20.0
gotchaGQL file linting is disabled by default since v0.21.2. If you relied on the plugin for GraphQL syntax validation in `.gql` or `.graphql` files, it will no longer function unless explicitly re-enabled.
fix
To re-enable GraphQL linting, add `pluginOptions.apollo.lintGQL: true` to your `vue.config.js` file.
affects: >=0.21.2
gotchaVersion 0.18.1 included an update to `nodemon` to fix a known vulnerability. While not a direct breaking change to user code, it's a critical security update for the optional GraphQL server component.
fix
Ensure `vue-cli-plugin-apollo` is updated to at least v0.18.1 to mitigate potential security risks associated with older `nodemon` versions in the development server.
affects: >=0.18.1
Errors
Common errors & fixes
GraphQL Introspection query incompatible with graphql@15
The schema generation command uses an introspection query that may be incompatible with specific versions of the `graphql` library, notably version 15.
fix
Update `vue-cli-plugin-apollo` to v0.22.2 or later, which includes a fix to use `getIntrospectionQuery` with `graphql@15`.
ENOENT: no such file or directory, stat 'path/to/file'
During project generation or when running `apollo:schema:generate`, the plugin might encounter file system errors due to missing paths or incorrect permissions.
fix
Verify that the paths specified in `vue.config.js` for schema generation or API sources exist and that the running process has appropriate read/write permissions. Ensure all relevant files are present.
Apollo link configuration ignored when websocketsOnly is true
A bug in earlier versions caused custom `link` options to be ignored when `websocketsOnly` was set to `true` in the Apollo client configuration.
fix
Update `vue-cli-plugin-apollo` to v0.22.2 or later, which contains a fix for this specific link configuration issue.
onResetStore hook expects a Promise
The `onResetStore` callback function in the Apollo client configuration expects to return a Promise, but might have been implemented as a synchronous function in older setups.
fix
Ensure that your `onResetStore` implementation, if used, consistently returns a `Promise`, for example, by making it an `async` function or explicitly returning `Promise.resolve()`.
Can't reexport the named export 'Name of the module' from non EcmaScript module (only default export is available)
This error can occur in some build environments, often related to how CommonJS and ESM modules are re-exported or consumed, particularly with `graphql` or `graphql-tag` packages.
fix
Ensure all related `graphql` and `graphql-tag` dependencies are at compatible versions. This error was sometimes resolved by simply installing `vue-cli-plugin-apollo`, as it correctly configures the environment. If it persists, check your `webpack` or `babel` configuration for module resolution issues.
Upgrade
Version history
0.22.2latest on npm
Audit
Dependencies
@vue/cli-shared-utilsrequiredRequired for Vue CLI plugin functionality.
typescriptoptionalPeer dependency for projects using TypeScript, enabling proper type checking and schema generation for TypeScript files.
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources