question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: (0 , _client.makeVar) is not a function

See original GitHub issue

Intended outcome: Upgraded from 3.4.11 to 3.4.12 and tried to run tests and expected everything go smoothly because there shouldn’t be any breaking changes.

Actual outcome: Got this failure:

  ● Test suite failed to run
    TypeError: (0 , _client.makeVar) is not a function

when importing makeVar like it is suggested in the docs (https://www.apollographql.com/docs/react/local-state/reactive-variables/):

import { makeVar } from '@apollo/client'

Got it working by changing the import to:

import { makeVar } from '@apollo/client/cache'

but then I ran into different issues (https://github.com/apollographql/apollo-client/issues/8814)

How to reproduce the issue: import makeVars:

import { makeVar } from '@apollo/client'

Versions

  System:
    OS: macOS 11.6
  Binaries:
    Node: 14.17.6 - ~/.nvm/versions/node/v14.17.6/bin/node
    Yarn: 1.22.4 - ~/.yarn/bin/yarn
    npm: 7.22.0 - ~/.nvm/versions/node/v14.17.6/bin/npm
  Browsers:
    Chrome: 93.0.4577.82
    Edge: 93.0.961.52
    Firefox: 91.0.2
    Safari: 14.1.2
  npmPackages:
    @apollo/client: 3.4.12 => 3.4.12
    apollo-link-logger: 2.0.0 => 2.0.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
johgoecommented, Sep 20, 2021

Same issue with gql. gql is undefined debugging it in our jest tests.

Sample Code

import { gql } from '@apollo/client';

export const whoamiQuery = gql`query Whoami {
  whoami {
    username,
    firstName,
    lastName,  
  }
}`;
2reactions
hamza-iqbal-hicommented, Jul 21, 2022

Still getting this issue when testing with Jest. Apollo Client Version : 3.5.10,

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Apollo Client useQuery Hook gql Uncaught TypeError ...
But the defined query const of will return me an error which is: Uncaught TypeError:(...) is not a function and thus the page...
Read more >
Reactive variables - Apollo GraphQL Docs
This code creates a reactive variable with an empty array as its initial value. Important: The return value of makeVar is a function...
Read more >
Pitfalls I fell into during Apollo Client 3.0 migration
Recently I worked on migrating Apollo Client to 3.0 from 2.6 in our project. ... with an error message saying TypeError:(0, _client.gql) is...
Read more >
gql TypeError: Object(...) is not a function - Code Grepper
gql TypeError: Object(...) is not a function. Add Answer | View In TPC Matrix. Technical Problem Cluster First Answered On March 17, 2020...
Read more >
apollo-client - Awesome JS
A fully-featured, production ready caching GraphQL client for every UI framework ... Fix various flaky tests before publishing @apollo/client@v3.7.0-rc.0 by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found