...

/

Enabling Communication with the Server

Enabling Communication with the Server

Learn to update data on a GraphQL server using mutations.

We need to configure two places in our client to ensure it will talk to our local GraphQL server. The first of these is in our client.tsx file. This is the file that tells our ApolloProvider component where to find our GraphQL server. Let’s change this file to send our GraphQL operations to the new local server instead:

Press + to interact
import { ApolloClient, InMemoryCache } from "@apollo/client";
const client = new ApolloClient({
uri: "{{EDUCATIVE_LIVE_VM_URL}}:3000",
cache: new InMemoryCache(),
});
export default client;

The other place we need to update is in codegen.yml, the configuration file for our GraphQL Code Generator.

Press + to interact
overwrite: true
schema: "{{EDUCATIVE_LIVE_VM_URL}}:3000"
...

This change will tell GraphQL Code Generator to generate the TypeScript types and functions in src/generated/graphql.tsx from our local GraphQL server. The types generated here will be the same, as the two servers—old and new—provide the same GraphQL schema. Even though we are not ...