react js + apollo client v3 + aws app syncy giving buffer error

Viewed 158

here is my refrence https://github.com/awslabs/aws-mobile-appsync-sdk-js#using-authorization-and-subscription-links-with-apollo-client-v3-no-offline-support

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { createAuthLink } from "aws-appsync-auth-link";
import { createSubscriptionHandshakeLink } from "aws-appsync-subscription-link";
import appSyncConfig from "./aws-exports";
import { ApolloProvider, createHttpLink, ApolloClient, InMemoryCache, ApolloLink } from '@apollo/client';

const url = appSyncConfig.aws_appsync_graphqlEndpoint;
const region = appSyncConfig.aws_appsync_region;
const auth = {
  type: appSyncConfig.aws_appsync_authenticationType,
  apiKey: appSyncConfig.aws_appsync_apiKey,
};

const httpLink = createHttpLink({ uri: url });

const link = ApolloLink.from([
  createAuthLink({ url, region, auth }),
  createSubscriptionHandshakeLink({ url, region, auth }, httpLink),
]);

const client = new ApolloClient({
  link,
  cache: new InMemoryCache(),
});


ReactDOM.render(
  <ApolloProvider client={client}>
    <App />
  </ApolloProvider>,
  document.getElementById('root')
);

package.json

"dependencies": { "@apollo/client": "^3.5.7", "aws-appsync-auth-link": "^3.0.7", "aws-appsync-subscription-link": "^3.0.9", "graphql": "^16.2.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-router-dom": "^6.2.1", },

error: enter image description here

0 Answers
Related