Akryum / Akryum/vue-cli-plugin-apollo

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

Aperta
#319 2 commenti 5 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
477
Fork
109
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### 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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.