Comments (14)
Implemented in release 1.2.0.
from apollo.
Or maybe:
export default {
...
apollo: {
user: {
query: FETCH_CURRENT_USER,
skip() {
return !this.isAuthenticated
},
// Or default value
skip: false,
...
}
},
methods: {
disableUserQuery() {
// Change skip value
this.$apollo.queries.user.skip = true
},
},
}
The last part is about controlling the apollo query programmatically if needed.
from apollo.
In release note there is no comments about it
There is issue
In documentation
https://vue-apollo.netlify.com/guide/apollo/special-options.html#skip-all
only skipAll
is presented.
I spend some time to find proper usage example and I can't so there is
apollo: {
me: {
skip: !isUerLoggedIn(),
query: gql`query {
me { id name rating numberOfGrades }
}`
}
},
Example like this could be placed on page because of there is only skipAll with $ sign.
https://vue-apollo.netlify.com/guide/apollo/special-options.html#skip-all
from apollo.
Hey everyone,
is the skip option also available in the apollo-composable Composition API for Vue 3? It does not seem to be implemented yet. https://v4.apollo.vuejs.org/api/use-query.html#parameters
Thanks.
from apollo.
This is a very good idea. I'm thinking of something like this:
export default {
...
apollo: {
user: {
query: FETCH_CURRENT_USER,
enabled() {
return this.isAuthenticated
},
...
}
},
methods: {
disableUserQuery() {
this.$apollo.queries.user.enabled = false
},
},
}
from apollo.
Would you mind explaining that a bit? It seems a little cumbersome. I'm not sure about the disableUserQuery
part. And I think skip()
would be better than enabled()
since that is the preferred term in the apollo docs.
from apollo.
I like that! :D I think it makes sense that way and will be a great feature :D
from apollo.
@Akryum Woot! I'll try this out and let you know how it goes. Can't wait! :)
from apollo.
Hello @Rick-McClatchie I need this option too but I can't find it, I guess it's missing, should we open a new feature request? it's reaaaally useful
from apollo.
I found a way to do it with the enabled
option
from apollo.
That's not working for me.
I tried this:
export function useSearch(params) {
const { result, loading, error, fetchMore } = useQuery(search, params, {
enabled: computed(() => !!params.value?.searchTerm),
});
const response = useResult(result, null, (data) => data.search);
return { response, loading, error, fetchMore };
}
And I get an error stating: Type 'ComputedRef' is not assignable to type 'boolean'
from apollo.
Has anyone found a way to integrate the skip option into their Vue js Apollo app? We need this feature badly for async validation. Kinda crazy that there is no way to skip first query without using enabled options (which automatically calls query when changed to true).
from apollo.
Since the third argument options
of useQuery
can receive a Ref
or a ReactiveFunction
, there is no need to make the option enabled
can too.
Instead of making enabled
reactive, we can just make the whole options
reactive.
Example:
const variables = ref(something);
useQuery(
document,
variables,
() => ({ enabled: !!variables.value }), // make `options` reactive
);
from apollo.
Example in the docs here
from apollo.
Related Issues (20)
- Not work with 3.2.25 HOT 2
- Make `provideApolloClient` default client disposable.
- Remove automatic subscription retry on error
- Can't receive messages in a chat using subscription
- skip() doesn't skip query HOT 1
- @vue/apollo-ssr doesn't work in SSR mode
- Fragments aren't returned in results when using useQuery/useLazyQuery reactive refs HOT 2
- Using vue-apollo-composable inside a Pinia setup store HOT 2
- `useApolloClient` checks wrong conditions before calling `inject()`
- useQuery blocks page load on 4.0.0 HOT 2
- useQuery with fetchPolicy: cache-only does not return expected data HOT 3
- Doesn't update the data after a mutation if `enabled` is `false` in `useQuery`
- Queries are not executed in given order
- @vue/[email protected] has a peer dependency conflict with Vue 3 HOT 4
- [docs] The installation guide is very bad HOT 1
- Refetch with New Variables Overrides Other Existing Refetches HOT 1
- `onBeforeUnmount` hook in `useQuery` is undesirable when used in pinia store HOT 1
- [Documentation] Composition API + Options API Configuration, how to make it work together? HOT 2
- Updating the `variables` ref does not work when using the function form
- Production breaks, dev mode works (Apollo client with id default not found.) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo.