We currently use graphql-codegen
to generate React Hooks to query our GraphQL server.
Given we currently have 2 endpoints, we do a Split like so:
const endpoints = ApolloLink.split(
operation => operation.getContext().serviceName === 'ServiceB',
SampleLink1
SampleLink2
);
What this means is that we need to provide that serviceName context variable everyime we want to reach ServiceB.
Given we have 2 calls to graphql-codegen
(one per Service that has their own schema / settings) is there a way to automatically add the baseOptions
with the correct context.
Otherwise we need to keep doing this:
const someQueryQuery = useSomeEntityQuery({
variables: { id },
context: {
serviceName: 'ServiceB',
},
});
But I'd prefer if context had a default and I just did this:
const someQueryQuery = useSomeEntityQuery({
variables: { id },
});
Basically the question is can we have a default context for code generated via graphql-codegen