Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not work with 3.2.25 #1517

Open
keyiis opened this issue Nov 6, 2023 · 2 comments
Open

Not work with 3.2.25 #1517

keyiis opened this issue Nov 6, 2023 · 2 comments

Comments

@keyiis
Copy link

keyiis commented Nov 6, 2023

Describe the bug
I add Apollo client in main.ts, like this:

const app = createApp(App);

// HTTP connection to the API
    let url = import.meta.env.VITE_NODE_API + '/graphql';
    console.log(url)
    const httpLink = createHttpLink({
        // You should use an absolute URL here
        uri: url,
    })

    // Cache implementation
    const cache = new InMemoryCache()

    // Create the apollo client
    const apolloClient = new ApolloClient({
        link: httpLink,
        cache,
    })

    const apolloProvider = createApolloProvider({
        defaultClient: apolloClient,
    })

app.use(apolloProvider).use(ElementPlus).use(Vant).use(store).use(router).mount('#app')

Then I run my vue project. The following error occurs

Versions
vue:3.2.25
vue-apollo: I don't konw
@apollo/client:3.8.7

My package.json
{
"name": "client",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite --config vite.config.ts",
"build": "vue-tsc --noEmit && vite --config vite.config.ts build",
"preview": "vite preview"
},
"dependencies": {
"@apollo/client": "^3.8.7",
"@element-plus/icons-vue": "^2.0.10",
"@neysf/qiyu-web-sdk": "^1.1.1",
"@vant/touch-emulator": "^1.4.0",
"@vue/apollo-composable": "^4.0.0-beta.11",
"@vue/apollo-option": "^4.0.0-beta.9",
"axios": "^0.27.2",
"dayjs": "^1.11.7",
"element-plus": "^2.2.32",
"graphql": "^16.8.1",
"graphql-tag": "^2.12.6",
"string-similarity-js": "^2.1.4",
"ts-md5": "^1.3.1",
"vant": "^4.0.10",
"vue": "^3.2.25",
"vue-router": "^4.0.15",
"vuex": "^4.0.2"
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.3.3",
"sass": "^1.52.1",
"sass-loader": "^13.0.0",
"typescript": "^4.5.4",
"vite": "^2.9.9",
"vue-tsc": "^0.34.7"
}
}

@keyiis
Copy link
Author

keyiis commented Nov 6, 2023

I discovered the cause of the error, When vue compile node_modules/graphql/jsutils/instanceOf.mjs,the globalThis.process.env.NODE_ENV will be converted to globalThis."development" .
1699259113469

@petunmar
Copy link

I discovered the cause of the error, When vue compile node_modules/graphql/jsutils/instanceOf.mjs,the globalThis.process.env.NODE_ENV will be converted to globalThis."development" . 1699259113469

I also ran into this problem and it is currently being discussed in a thread on the graphql-js repository. You can find the ongoing discussion here: graphql/graphql-js#3978.

There I found a workaround that worked for me. By changing the check from:

globalThis.process && globalThis.process.env.NODE_ENV === 'production'

to

globalThis.process && globalThis.process.env['NODE_ENV'] === 'production'

I was able to resolve the problem in my project. Although this is just a temporary solution until a more permanent fix is implemented in the library.

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

No branches or pull requests

2 participants