From 536441ac9b71fe1bb1156c3e556758f9fe2839f9 Mon Sep 17 00:00:00 2001 From: vh-fullstack <109882814+vh-fullstack@users.noreply.github.com> Date: Mon, 1 Sep 2025 14:58:28 -0400 Subject: [PATCH 1/3] Fix ApolloClient initialization for newer versions 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. --- src/content/8/en/part8b.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/content/8/en/part8b.md b/src/content/8/en/part8b.md index b6ab9817199..2dffc3e7535 100644 --- a/src/content/8/en/part8b.md +++ b/src/content/8/en/part8b.md @@ -35,11 +35,13 @@ We'll start with the following code for our application: import ReactDOM from 'react-dom/client' import App from './App' -import { ApolloClient, InMemoryCache, gql } from '@apollo/client' +import { ApolloClient, InMemoryCache, HttpLink, gql } from '@apollo/client' const client = new ApolloClient({ - uri: 'http://localhost:4000', cache: new InMemoryCache(), + link: new HttpLink({ + uri: 'http://localhost:4000', + }), }) const query = gql` From 8a1181db34b2ee4cb6cca0bae0e03a0eb57d1e39 Mon Sep 17 00:00:00 2001 From: vh-fullstack <109882814+vh-fullstack@users.noreply.github.com> Date: Mon, 1 Sep 2025 15:32:23 -0400 Subject: [PATCH 2/3] Add HttpLink to a lower section --- src/content/8/en/part8b.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/content/8/en/part8b.md b/src/content/8/en/part8b.md index 2dffc3e7535..db06e188282 100644 --- a/src/content/8/en/part8b.md +++ b/src/content/8/en/part8b.md @@ -93,8 +93,10 @@ import { } from '@apollo/client' const client = new ApolloClient({ - uri: 'http://localhost:4000', cache: new InMemoryCache(), + link: new HttpLink({ + uri: 'http://localhost:4000', + }), }) ReactDOM.createRoot(document.getElementById('root')).render( From c6502102390d9fb51ad2d3dc0bc384b6f0e82585 Mon Sep 17 00:00:00 2001 From: vh-fullstack <109882814+vh-fullstack@users.noreply.github.com> Date: Tue, 2 Sep 2025 10:11:57 -0400 Subject: [PATCH 3/3] fix(apollo): swap 'link' and 'cache' to original order, add HttpLink import --- src/content/8/en/part8b.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content/8/en/part8b.md b/src/content/8/en/part8b.md index db06e188282..3937376aae6 100644 --- a/src/content/8/en/part8b.md +++ b/src/content/8/en/part8b.md @@ -89,6 +89,7 @@ import App from './App' import { ApolloClient, ApolloProvider, // highlight-line + HttpLink, InMemoryCache, } from '@apollo/client'