Skip to content

Conversation

vh-fullstack
Copy link

@vh-fullstack vh-fullstack commented Sep 1, 2025

This PR updates the ApolloClient initialization in the course material to be compatible with recent versions (tested with 4.0.3).

Previously, the client was initialized as:

const client = new ApolloClient({
uri: 'http://localhost:4000',
cache: new InMemoryCache(),
})

This setup triggers the following error on newer Apollo Client versions:

Uncaught Invariant Violation: To initialize Apollo Client, you must specify a 'link' property.

The updated initialization adds an explicit HttpLink:

const client = new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({ uri: 'http://localhost:4000' }),
});

This ensures compatibility with current versions while preserving the intended functionality.

Corresponding course part: Part 8

The previous ApolloClient setup used:

const client = new ApolloClient({
  uri: 'http://localhost:4000',
  cache: new InMemoryCache(),
})

With recent Apollo Client versions (4.0.3), this triggers:

Uncaught Invariant Violation: To initialize Apollo Client, you must specify a 'link' property.

This update adds an explicit HttpLink:

const client = new ApolloClient({
  cache: new InMemoryCache(),
  link: new HttpLink({ uri: 'http://localhost:4000' }),
});

This ensures compatibility with newer Apollo Client releases without changing existing functionality.
@vejol vejol added the part 8 label Sep 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants