vuejs / apollo

🚀 Apollo/GraphQL integration for VueJS
http://apollo.vuejs.org
MIT License
6.02k stars 522 forks source link

Apollo composable could not resolve dependency of GraphQL #1156

Open roosht3 opened 3 years ago

roosht3 commented 3 years ago

Describe the bug @vue/apollo-composable is not working with graphql 15.5

To Reproduce Steps to reproduce the behavior:

  1. npm install graphql // latest 15.5
  2. npm install @vue/apollo-composable
  3. fails with below error
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: booking-engine@1.0.0
npm ERR! Found: graphql@15.5.0
npm ERR! node_modules/graphql
npm ERR!   graphql@"^15.5.0" from the root project
npm ERR!   peer graphql@"^14.0.0 || ^15.0.0" from @apollo/client@3.3.11
npm ERR!   node_modules/@apollo/client
npm ERR!     @apollo/client@"^3.3.11" from the root project
npm ERR!     peer @apollo/client@"^3.2.1" from @vue/apollo-composable@4.0.0-alpha.12
npm ERR!     node_modules/@vue/apollo-composable
npm ERR!       @vue/apollo-composable@"*" from the root project
npm ERR!   1 more (subscriptions-transport-ws)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer graphql@"^14.5.8" from @vue/apollo-composable@4.0.0-alpha.12
npm ERR! node_modules/@vue/apollo-composable
npm ERR!   @vue/apollo-composable@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-02-28T04_58_19_115Z-debug.log

Expected behavior Apollo composable must be compatible with graphql 15.5

Versions nuxt: "^2.14.12" @vue/apollo-composable: "^4.0.0-alpha.12" @apollo/client: "^3.3.11"

heresie commented 3 years ago

Same problem here.

To Reproduce Steps to reproduce the behavior:

# Create a temporary folder & go in it
mkdir -p /tmp/tests && cd $_

# Run an Node 15.11 Docker container
docker run -it -w /spa -v $PWD:/spa --rm --name vueapollo --entrypoint sh -p 0.0.0.0:8080:8080/tcp node:15.11-alpine3.11

~~ INSIDE DOCKER CONTAINER FROM HERE ~~

# Install vue/cli & create vue3 project
npm install -g @vue/cli
vue create vueapollo

Vue CLI v4.5.11
? Please pick a preset: Manually select features
? Check the features needed for your project: Choose Vue version, TS, Router, CSS Pre-processors, Linter
? Choose a version of Vue.js that you want to start the project with 3.x (Preview)
? Use class-style component syntax? No
? Use Babel alongside TypeScript (required for modern mode, auto-detected polyfills, transpiling JSX)? No
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with dart-sass)
? Pick a linter / formatter config: Basic
? Pick additional lint features: Lint on save
? Where do you prefer placing config for Babel, ESLint, etc.? In dedicated config files
? Save this as a preset for future projects? No
? Pick the package manager to use when installing dependencies: NPM

🎉  Successfully created project vueapollo.
👉  Get started with the following commands:

# Go in project folder & install dependency
cd vueapollo
npm install @vue/apollo-composable --save

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: vueapollo@0.1.0
npm ERR! Found: vue@3.0.7
npm ERR! node_modules/vue
npm ERR!   vue@"^3.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@">= 2.5 < 3" from @vue/composition-api@1.0.0-rc.3
npm ERR! node_modules/@vue/composition-api
npm ERR!   peer @vue/composition-api@"^1.0.0-beta.16" from @vue/apollo-composable@4.0.0-alpha.12
npm ERR!   node_modules/@vue/apollo-composable
npm ERR!     @vue/apollo-composable@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-03-10T14_18_35_598Z-debug.log
rabrowne85 commented 3 years ago

I had a similar issue and eventually found that the --legacy-peer-deps flag was necessary. i.e.

$ npm install @vue/apollo-composable --save --legacy-peer-deps

I'm sure if it will solve your issues, but worth a shot. From my understanding the version of NPM was the "issue" and the options are:

  1. Downgrade NPM to the previous version
  2. Use the --legacy-peer-deps flag which:

bypasses peerDependency auto-installation; it tells NPM to ignore peer deps and proceed with the installation anyway stackoverflow