I have to create two links using graphql, the first it's to be able to upload files to the server and the seconde it's to able to using the subscription of graphql but I get the following error:
"Type 'ApolloLink' is missing the following properties from type 'ApolloLink': onError, setOnError"
"The expected type comes from property 'link' which is declared here on type 'ApolloClientOptions'"
import { ApolloClient, InMemoryCache } from '@apollo/client';
import { createUploadLink } from 'apollo-upload-client';
import { getAccessToken } from '../pages/Auth/isAuth';
import { split } from 'apollo-link';
import { WebSocketLink } from 'apollo-link-ws';
import { getMainDefinition } from 'apollo-utilities';
const accessToken = getAccessToken();
const wsLink = new WebSocketLink({
uri: `ws://localhost:4000/graphql`,
options: {
reconnect: true,
},
});
const uploadlink = createUploadLink({
uri: 'http://localhost:4000/graphql',
credentials: 'include',
headers: {
authorization: accessToken ? `Bearer ${accessToken}` : '',
},
});
const link = split(
// split based on operation type
({ query }) => {
const definition = getMainDefinition(query);
return (
definition.kind === 'OperationDefinition' &&
definition.operation === 'subscription'
);
},
wsLink,
uploadlink
);
const client = new ApolloClient({
cache: new InMemoryCache(),
link: link, //error here
});
export default client;