Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new ApolloLink(operation => {
const uri = selectURI(operation, fetchUri)
const context = operation.getContext()
// Apollo Engine client awareness:
// https://apollographql.com/docs/platform/client-awareness
const {
// From Apollo Client config.
clientAwareness: { name, version } = {},
headers
} = context
const contextConfig = {
http: context.http,
options: context.fetchOptions,
credentials: context.credentials,
headers: {
return new ApolloLink(operation => {
let chosenURI = selectURI(operation, uri);
const context = operation.getContext();
// `apollographql-client-*` headers are automatically set if a
// `clientAwareness` object is found in the context. These headers are
// set first, followed by the rest of the headers pulled from
// `context.headers`. If desired, `apollographql-client-*` headers set by
// the `clientAwareness` object can be overridden by
// `apollographql-client-*` headers set in `context.headers`.
const clientAwarenessHeaders = {};
if (context.clientAwareness) {
const { name, version } = context.clientAwareness;
if (name) {
clientAwarenessHeaders['apollographql-client-name'] = name;
}
if (version) {
((operation: Operation) => {
const context = operation.getContext();
const contextConfig = {
http: context.http,
options: context.fetchOptions,
credentials: context.credentials,
headers: context.headers,
};
//may throw error if config not serializable
return selectURI(operation, uri) + JSON.stringify(contextConfig);
});
const batchHandler = (operations: Operation[]) => {
const chosenURI = selectURI(operations[0], uri);
const context = operations[0].getContext();
const clientAwarenessHeaders = {};
if (context.clientAwareness) {
const { name, version } = context.clientAwareness;
if (name) {
clientAwarenessHeaders['apollographql-client-name'] = name;
}
if (version) {
clientAwarenessHeaders['apollographql-client-version'] = version;
}
}
const contextConfig = {
http: context.http,