Akryum / Akryum/vue-cli-plugin-apollo

Why the type of the link property in ApolloClientConfig is string instead of ApolloLink

Open
#319 2 comments 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
477
Forks
109
PR merge metrics
No merged PRs in 30d

Description

### Question

Why the type of the link property in ApolloClientConfig is String instead of ApolloLink

### Description

I want to use my 'authMiddlewareLink' instead of the default link。
But I got these problems from VSCode

> Type 'ApolloLink' is not assignable to type 'string'.

### Code
```
const authMiddlewareLink = new ApolloLink((operation, forward) => {
const token = getUserToken();
const headers = token ? { 'API-TOKEN': token } : {};
operation.setContext({
headers,
});
return forward(operation);
});

export const { apolloClient } = createApolloClient({
link: authMiddlewareLink,
...defaultOptions,
});
```

### Version
0.21.3

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.