title: Using custom Apollo Client with AWS AppSync
body: <h1>Background</h1>
  <p>In a new project I am working on we are looking into using AppSync for our GraphQL server (with Amplify). However, as it depends on an old version of Apollo Client (2.4.6), and Apollo Client has introduced major changes in version 3.0, using the AwsAppSyncClient is not optimal. We cannot wait for AppSync to migrate to Apollo Client 3.0 either, so I am wondering if it is best to use a custom client with Apollo Client 3.0 for now and migrate over to AwsAppSyncClient once their Apollo dependency is migrated to 3.0. Is this a good idea? The current implementation of this can be found below. However, this poses a few new questions.</p>
  <p>(This is my first question on Stack Overflow, so hope this is not too much at once!)</p>
  <p>I have done a fair bit of research, but am still new to the topic of GraphQL, Apollo, AppSync and Amplify, so thought it would be best to ask the experts out there!</p>
  <h1>Questions</h1>
  <ul>
  <li>How to best combine Apollo Client 3.0 with AppSync (see implementation below)? What do you lose by not using AwsAppSyncClient?</li>
  <li>With using a custom Apollo Client with AppSync, is it then possible to query both local and remote data in the same query (e.g. with the @client tag)?</li>
  <li>Is there a way to handle local state management with AwsAppSyncClient like there is with ApolloClient using e.g. <a href="https://www.apollographql.com/docs/react/local-state/reactive-variables/" rel="noreferrer">reactive variables</a>?</li>
  </ul>
  <h2>Additional question about using AppSync:</h2>
  <p>(Don't know whether I should create a separate question for this?)</p>
  <ul>
  <li>How does querying with AppSync actually work with regards to designing queries from the client? As far as I understand with GraphQL, the whole point is to combine what would have been multiple REST calls, while also only asking for the fields that are actually relevant. With AppSync and codegen, however, the <code>queries.js</code> and <code>mutations.js</code> files are automatically generated with only &quot;basic&quot; queries for each model, with all fields included; much like REST calls. Why is this being done, and how to work with it from the client side?</li>
  </ul>
  <p>Using AppSync with custom client (Apollo Client 3.0)</p>
  <pre><code>import React from &quot;react&quot;;
  import ReactDOM from &quot;react-dom&quot;;
  import App from &quot;./App&quot;;
  import Amplify from &quot;aws-amplify&quot;;
  import {
    ApolloProvider,
    ApolloClient,
    ApolloLink,
    createHttpLink,
    InMemoryCache,
    makeVar
  } from &quot;@apollo/client&quot;;
  import { createAuthLink } from &quot;aws-appsync-auth-link&quot;;
  
  import awsExports from &quot;./aws-exports&quot;;
  
  
  Amplify.configure(awsExports);
  
  const sidebarCollapsedVar = makeVar(false);
  
  const link = ApolloLink.from([
    createAuthLink({
      url: awsExports.aws_appsync_graphqlEndpoint,
      region: awsExports.aws_appsync_region,
      auth: {
        type: awsExports.aws_appsync_authenticationType,
        apiKey: awsExports.aws_appsync_apiKey,
      },
    }),
    createHttpLink({ uri: awsExports.aws_appsync_graphqlEndpoint }),
  ]);
  
  const client = new ApolloClient({
    link,
    cache: new InMemoryCache({
      typePolicies: {
        Query: {
          fields: {
            sidebarCollapsed: {
              read() {
                return sidebarCollapsedVar();
              },
            },
          },
        },
      },
    }),
  });
  
  ReactDOM.render(
    &lt;React.StrictMode&gt;
      &lt;ApolloProvider client={client}&gt;
        &lt;App /&gt;
      &lt;/ApolloProvider&gt;
    &lt;/React.StrictMode&gt;,
    document.getElementById(&quot;root&quot;)
  );
  </code></pre>