-
-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript won't recognize fetchPolicy
value as valid
#936
Comments
I was able to write it in another way by using a function instead of a object and it has fixed the error:
But I still think there's a bug if you're not using it as a function. |
I'm experiencing the same problem in my App. When I write it this way, it fails: import userQuery from '@/graphql/queries/user/user.graphql';
export default {
apollo: {
user: {
query: userQuery,
fetchPolicy: 'cache-only',
prefetch: false,
},
},
} I've tracked it down to the If I import the `` type and cast my fetch policy to that type, then I'm good: import { WatchQueryFetchPolicy } from 'apollo-client';
import userQuery from '@/graphql/queries/user/user.graphql';
export default {
apollo: {
user: {
query: userQuery,
fetchPolicy: 'cache-only' as WatchQueryFetchPolicy,
prefetch: false,
},
},
} Going the function route like @richardaum suggested also solves my problem: import userQuery from '@/graphql/queries/user/user.graphql';
export default {
apollo: {
user() {
return {
query: userQuery,
fetchPolicy: 'cache-only',
prefetch: false,
};
},
},
} Any thoughts on what may be causing this or how it could be fixed? |
The first thing I see that could be potentially causing the issue is that you're both using If that doesn't work, you might try rolling back to v3.0.0.rc7. Some of the types changed in rc8 and it broke some of my stuff too. See issue #847. If it works then but not now, it might help track down the problem. |
@bbugh Thanks for reply! You have a point about how that component is exported. But this is the way how |
@richardaum I am facing similar issue with apollo-client (angular). Was this ever resolved? https://github.com/apollographql/apollo-client/issues/7681 |
I'm facing the similar issue on React as well. |
Describe the bug
When using
fetchPolicy
property on$apollo
inside a Single File Vue Component, typescript throws the following error on terminal output:The component is being defined the following way:
According to the docs, I should be able to use
fetchPolicy
this way:To Reproduce
Steps to reproduce the behavior:
apollo
property to itfetchPolicy
with a valid valuenpm run serve
Expected behavior
Typescript should not complain about valid values on
fetchPolicy
property.Versions
vue: 2.6.11
vue-apollo: 3.0.3
apollo-client: 2.6.8
Additional context
Using
this.$apollo.query
method withfetchPolicy
doesn't throw any related error, which could indicate this problem is related to the Typescript definition overapollo
property.The text was updated successfully, but these errors were encountered: