vuejs / apollo

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

No support for grapql 16.x / Apollo Client 3.x #1448

Open floppey opened 1 year ago

floppey commented 1 year ago

Describe the bug I'm trying to update our dependencies to use the latest version of graphql and apollo client, but I can't find a way to do this with vue-apollo.

Currently if I update graphql to the latest version, or any 16.x version I get an error because apollo-boost requires version 15.x

npm ERR! Conflicting peer dependency: graphql@15.8.0
npm ERR! node_modules/graphql
npm ERR!   peer graphql@"^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0" from apollo-boost@0.4.9
npm ERR!   node_modules/apollo-boost
npm ERR!     apollo-boost@"^0.4.9" from the root project

According to apollo's documentation apollo-boost should not be used with the latest version of @apollo/client.

As far as I can tell the current version of vue-apollo (3.1.0) is fairly outdated and does not support the latest version of @apollo/client. I did find what looks like a new version of vue-apollo, but now called @vue/apollo-composable. The documentation here is very lacking and after installing it and using the new package my project crashes due to a missing React dependency.

Installation instructions from https://v4.apollo.vuejs.org/guide/installation.html :

npm install --save graphql graphql-tag @apollo/client

Error when installing:

npm ERR! Conflicting peer dependency: react@18.2.0
npm ERR! node_modules/react
npm ERR!   peer react@"^18.2.0" from react-dom@18.2.0
npm ERR!   node_modules/react-dom
npm ERR!     peerOptional react-dom@"^16.8.0 || ^17.0.0 || ^18.0.0" from @apollo/client@3.7.4
npm ERR!     node_modules/@apollo/client
npm ERR!       @apollo/client@"*" from the root project

After installing with --legacy-peer-deps flag and trying to use ApolloClient from @apollo/client:

import { ApolloClient } from "@apollo/client";

I then get this error when I run the application:

X [ERROR] Could not resolve "react"

    node_modules/@apollo/client/react/context/ApolloContext.js:1:23:
      1 │ import * as React from 'react';

Expected behavior I'd like to be able to use an up to date version of ApolloClient in my vue application.

Versions vue: 3.2.37 vue-apollo: 3.1.0 @apollo/client: 3.7.4 @vue/apollo-composable: 4.0.0-beta.1

dominikklein commented 1 year ago

Normally it should be working fine, in our project we have no problems with the current GraphQL and Apollo-Client version.

I think the problem is that you need to use the "core" package directly after the update of the Apollo-Client 3:

import { ApolloClient } from '@apollo/client/core'

When you use the imports from @apollo/client the "react" dependency hooks in.

https://www.apollographql.com/docs/react/migrating/apollo-client-3-migration/#using-apollo-client-without-react

websitevirtuoso commented 1 year ago

yes/ I also don't have nay issue I am using latest versions of packages. vite, vue 3.3, gql 3. Apoolo v3 has some limitations in their TS when use imports. you can find related issues on their repo. It will be fixed in apollo package v4

riodw commented 1 year ago

This is the error I am getting:

[vite] error while updating dependencies:
Error: ENOENT: no such file or directory, open './node_modules/apollo-boost/lib/bundle.esm.js'

Edit: Fixed by running yarn add apollo-boost

  1. https://v4.apollo.vuejs.org/guide/installation.html
  2. https://v4.apollo.vuejs.org/guide-composable/setup.html Nothing in the docs ^ lists this as a dependency.