You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 14, 2023. It is now read-only.
I read the docs about terminating links, but what about the situations which we need to use the behavior of different terminating links?
My case is: I'm using apollo-upload-client for upload and I would like to use apollo-link-batch-http to improve performance request.
So this code says that I can't have 2 terminating links:
exportdefaultfunctioncreateApolloClient(initialState,ctx){// The `ctx` (NextPageContext) will only be present on the server.// use it to extract auth headers (ctx.req) or similar.consthttpLink=createUploadLink({uri: `${process.env.NEXT_PUBLIC_API_URL}/graphql`,credentials: 'same-origin',
fetch,});constbatchLink=newBatchHttpLink({uri: `${process.env.NEXT_PUBLIC_API_URL}/graphql`,credentials: 'same-origin',
fetch,});constauthLink=setContext((_,{ headers })=>{// get the authentication token from local storage if it existsconsttoken=Cookies.get('token');// return the headers to the context so httpLink can read themreturn{headers: {
...headers,authorization: token ? `Bearer ${token}` : "",}}});returnnewApolloClient({ssrMode: Boolean(ctx),link: from([authLink,batchLink,httpLink]),})}
What is the best approach in this kinda of problem?