@@ -35,10 +35,10 @@ We'll start with the following code for our application:
3535import ReactDOM from ' react-dom/client'
3636import App from ' ./App'
3737
38- import { ApolloClient , InMemoryCache , gql } from ' @apollo/client'
38+ import { ApolloClient , HttpLink , InMemoryCache , gql } from ' @apollo/client' ;
3939
4040const client = new ApolloClient ({
41- uri: ' http://localhost:4000' ,
41+ link : new HttpLink ({ uri: ' http://localhost:4000' }) ,
4242 cache: new InMemoryCache (),
4343})
4444
@@ -84,14 +84,11 @@ The application can communicate with a GraphQL server using the *client* object.
8484import ReactDOM from ' react-dom/client'
8585import App from ' ./App'
8686
87- import {
88- ApolloClient ,
89- ApolloProvider , // highlight-line
90- InMemoryCache ,
91- } from ' @apollo/client'
87+ import { ApolloClient , HttpLink , InMemoryCache } from ' @apollo/client' ;
88+ import { ApolloProvider } from ' @apollo/client/react' ; // highlight-line
9289
9390const client = new ApolloClient ({
94- uri: ' http://localhost:4000' ,
91+ link : new HttpLink ({ uri: ' http://localhost:4000' }) ,
9592 cache: new InMemoryCache (),
9693})
9794
@@ -112,7 +109,8 @@ Currently, the use of the hook function [useQuery](https://www.apollographql.com
112109The query is made by the <i >App</i > component, the code of which is as follows:
113110
114111``` js
115- import { gql , useQuery } from ' @apollo/client'
112+ import { gql } from ' @apollo/client' ;
113+ import { useQuery } from ' @apollo/client/react' ;
116114
117115const ALL_PERSONS = gql `
118116query {
@@ -245,7 +243,8 @@ The solution is as follows:
245243
246244``` js
247245import { useState } from ' react'
248- import { gql , useQuery } from ' @apollo/client'
246+ import { gql } from ' @apollo/client' ;
247+ import { useQuery } from ' @apollo/client/react' ;
249248
250249const FIND_PERSON = gql `
251250 query findPersonByName ($nameToSearch : String ! ) {
@@ -401,7 +400,8 @@ Let's create a new component for adding a new person to the directory:
401400
402401``` js
403402import { useState } from ' react'
404- import { gql , useMutation } from ' @apollo/client'
403+ import { gql } from ' @apollo/client' ;
404+ import { useMutation } from ' @apollo/client/react' ;
405405
406406const CREATE_PERSON = gql `
407407 // ...
@@ -686,7 +686,7 @@ Interesting lines on the code have been highlighted.
686686
687687` ` ` js
688688import { useState } from ' react'
689- import { useMutation } from ' @apollo/client'
689+ import { useMutation } from ' @apollo/client/react ' ;
690690
691691import { EDIT_NUMBER } from ' ../queries'
692692
0 commit comments