-
-
Notifications
You must be signed in to change notification settings - Fork 523
How to do query on button click? #121
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
Comments
You can either use export default {
data () {
return {
myVariables: null,
},
},
apollo: {
items: {
query: GQL_QUERY,
variables () {
return this.myVariables
},
skip () {
return !this.myVariables
},
},
},
methods: {
onButtonClick () {
this.myVariables = {
// ...
},
},
},
} |
Thanks for you reply. So with the |
I showed you two different ways already. 😄 |
Oh I see what you are saying. |
@Akryum thanks for the answer. I have another question:
|
@Akryum i got the answer. Just in case if someone wants to know the solution.
|
I want to say thanks first for this great Apollo integration!
I ran into some problem recently and got no answer after googling around. The scenario is pretty simple: I don't want the query to be called automatically when the page/components is loaded, I just want to call the query on button click.
So in React with react-apollo I can do something like this:
The 'client' prop comes from withApollo HOC
I wonder if there is a way to do this in vue-apollo?
Looked into this issue #36 , but I believe the answer provided does not meet my need, because "refetch" will simply do the query again with same query/variables. I am searching for a way in which every time I click the button I can get different queries according to my variables.
The text was updated successfully, but these errors were encountered: