apollo-angular
apollo-angular copied to clipboard
Types of property 'fetchPolicy' are incompatible.
Describe the bug
I get a compilation error if I use the option fetchPolicy.
To Reproduce
if I have a query that looks like this
const query = {
query: myQuery,
variables: {
id: id,
date: date
},
fetchPolicy: 'no-cache'
}
this.apollo.query(query);
I get
Types of property 'fetchPolicy' are incompatible.
Type 'string' is not assignable to type 'FetchPolicy'.
Expected behavior
adding the fetchPolicy option should not generate an error
Environment:
├── @angular/[email protected]
├── @apollo/[email protected]
├── [email protected]
├── [email protected]
└── [email protected]
Additional context
I temporarily solved this way:
I've copied the following line from the TS definition and added in my ts file
export declare type FetchPolicy = 'cache-first' | 'network-only' | 'cache-only' | 'no-cache' | 'standby'; // trying to fix a TS issue
Then run the query this way
const noCache:FetchPolicy = "no-cache"; //trick to fix it the TS error
const query = {
query: myQuery,
variables: {
id: id,
date: date
},
fetchPolicy: noCache
}
this.apollo.query(query);