Closed cyberco closed 3 years ago
Same problem when installing @vue/apollo-composable package.
Don't need import { provide } from '@vue/composition-api'
import { provide } from 'vue'
Don't need
import { provide } from '@vue/composition-api'
import { provide } from 'vue'
That's actually also what I have. I import provide
from vue
. That also makes me think why you would need to install vue/composition-api if you're using vue3?
I mean the console is complaining but everything seems to work so far... Does anyone know?
I have the following code, which works for me:
import {
ApolloClient,
createHttpLink,
InMemoryCache
} from "@apollo/client/core";
import { ApolloClients } from "@vue/apollo-composable";
import { createApp, h, provide } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
const cache = new InMemoryCache();
const apolloPrivateClient = new ApolloClient({
link: createHttpLink({ uri: "/internal/api/graphql" }),
cache
});
const apolloPublicClient = new ApolloClient({
link: createHttpLink({ uri: "/api/graphql" }),
cache
});
createApp({
setup() {
provide(ApolloClients, {
default: apolloPublicClient,
private: apolloPrivateClient
});
},
render() {
return h(App);
}
})
.use(store)
.use(router)
.mount("#app");
I don't remember the specifics but getting Vue Apollo to work is kind of hacky. As suggested in this video at some point you'd have to npm install react
to get it working. I don't know if this is still required thou.
If you import from @apollo/client/core
, you should be fine not installing react
.
True that, react is not needed but are there any fixes to get rid of the errors?
@Manubi if you type in like npm install --save @vue/apollo-composable --force, or --legacy-peer-deps; that will ignore peer-deps.
If you import from
@apollo/client/core
, you should be fine not installingreact
.
Not that it is the way to go, but perhaps when you attempt to catch some errors during the link.
Using ApolloLink class and try to make an ApolloClient using an error handler and an httplink with ApolloLink like:
const client = new ApolloClient({ link: ApolloLink.from([linkError, link]), cache, })
Not that vue-apollo does but apollo itself requires react as dependency, sadly it relies on it at some ends.
The docs need to be updated. @vue/composition-api
is a package for Vue 2.
The whole docs are a mess. You even don’t really know on what version you are… If you want to update something you get a 404.
Sorry for cross-posting, but I have also this issue
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
I doubt that the --force
option is what I should do...
how is this issue resolved? I have the same issue
error in ./node_modules/@vue/apollo-composable/dist/index.esm.js Module parse failed: Unexpected token (19:103) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders | var ApolloClients = Symbol("apollo-clients"); | function resolveDefaultClient(providedApolloClients, providedApolloClient) {
const resolvedClient = providedApolloClients ? providedApolloClients.default : providedApolloClient ?? void 0; | return resolvedClient; | }
@ ./src/main.ts 6:0-55 15:12-25 @ multi (webpack)-dev-server/client?http://192.168.1.9:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts
main.ts import { createApp, provide, h } from 'vue'; import { ApolloClients } from '@vue/apollo-composable'; import App from './App.vue'; import router from './router'; import store from './store'; import '../node_modules/bootstrap/dist/css/bootstrap.min.css'; import * as apolloClient from './apollo-client';
const app = createApp({ setup() { provide(ApolloClients, { default: apolloClient, }); }, render: () => h(App), });
app.use(store).use(router).mount('#app');
@engeman2008 You seem to be describing another issue. Are you perhaps using @vue/apollo-composable
version 4.0.0-alpha.13, which was released two days before your comment? If so, I think your issue is already being discussed: #1217.
@engeman2008 You seem to be describing another issue. Are you perhaps using
@vue/apollo-composable
version 4.0.0-alpha.13, which was released two days before your comment? If so, I think your issue is already being discussed: #1217.
Yes, Thank you. This solved my issue
I'm trying to get vue-apollo up and running using:
Using the following simple Vue app (CompositionAPI) that follows the guide for composable API:
But this throws: