Open richardmtsr opened 2 years ago
I'm getting the same error as well.
import { gql } from 'graphql-tag'
works, whereas import { gql } from '@apollo/client'
does not work.
Thanks @raopg - i have seen this elsewhere but doesn't work for me, this yields a TypeError: Object(...) is not a function
error on the same line.
Does anyone know what causes this issue? Might help me work around it. Seems strange that the import from @apollo/client
doesn't work with it's own hooks.
i am also getting this issue from earlier and i change the version of apollo client to 3.2.4 it works now again i am getting this issue ....adding graphql-tag also doesnot works ..
We ended up locking Apollo version to 3.4.16 and things are working.
This may be a webpack misconfiguration. I ran into this issue with create-react-app, since its webpack config doesn't correctly handle .cjs
file extensions (more info and fix here). @apollo/client
uses this extension as of v3.5.x (previously it used *.cjs.js
)
Hello, 👋🏼 I am currently working on a React Native Expo project and I hit the .cjs
issue and added a metro.config.js
file with the following:
const { getDefaultConfig } = require('@expo/metro-config')
const config = getDefaultConfig(__dirname)
config.resolver.sourceExts.push('cjs')
module.exports = config
This indeed fixed the .cjs
error but now I am stuck on a TypeError I can't seem to figure out -
TypeError: undefined is not a function (near '...(0, _client.gql)...')
- ... 9 more stack frames from framework internals
anyone else hitting this error?
It looks like having a root folder named graphql
was causing a problem! I just renamed the folder and it seems like it is working again. 😅
Intended outcome: Using
useQuery
andgql
results in a query being sent to GraphQL.Actual outcome: Compiler throws an error complaining that
typeerror: _apollo_client__webpack_imported_module_0__.gql is not a function
The line in question in the below example is:const { loading, error, data } = useGraphQLQuery(EXCHANGE_RATES);
How to reproduce the issue:
App.tsx
Thread.tsx
Versions
package.json