Skip to content

Conversation

vh-fullstack
Copy link

In the current course material, ApolloProvider is imported as:

import {
ApolloClient,
ApolloProvider,
InMemoryCache,
} from '@apollo/client'

With recent versions of Apollo Client, this produces the error:

Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/@apollo_client.js?v=8222a40d' does not provide an export named 'ApolloProvider'

This happens because ApolloProvider is now exported from a separate submodule for React.

The fix is to import ApolloProvider from '@apollo/client/react' instead:

import { ApolloProvider } from '@apollo/client/react';

This follows the official Apollo documentation:
https://www.apollographql.com/docs/react/get-started#step-4-connect-your-client-to-react

Corresponding course part: Part 8

In the current course material, ApolloProvider is imported as:

import {
  ApolloClient,
  ApolloProvider,
  InMemoryCache,
} from '@apollo/client'

With recent versions of Apollo Client, this produces the error:

Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/@apollo_client.js?v=8222a40d' does not provide an export named 'ApolloProvider'

This happens because ApolloProvider is now exported from a separate submodule for React. 

The fix is to import ApolloProvider from '@apollo/client/react' instead:

import { ApolloProvider } from '@apollo/client/react';

This follows the official Apollo documentation:
https://www.apollographql.com/docs/react/get-started#step-4-connect-your-client-to-react

**Corresponding course part:** Part 8
### Additional update: useQuery import
Similar to ApolloProvider, useQuery should also be imported from '@apollo/client/react'.

Previous import:
import { useQuery } from '@apollo/client'

Fix:
import { useQuery } from '@apollo/client/react'

This aligns with the official Apollo documentation and prevents module resolution errors in recent versions.
@vh-fullstack vh-fullstack changed the title Fix ApolloProvider import for React compatibility Fix Apollo React imports (ApolloProvider, useQuery) Sep 1, 2025
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

Successfully merging this pull request may close these issues.

1 participant