Sorry for the title. Not sure how to describe it best.
I have following query:
query allPalettes ($first: Int, $skip: Int, $orderBy: PaletteOrderBy) {
allPalettes(first: $first, skip: $skip, orderBy: $orderBy) {
id
title
colors
votes {
id
user {
id
}
}
}
totalCount: _allPalettesMeta {
count
}
}
So there are two datasets allPallettes and totalCount.
However I am not sure how to grab them in vue-apollo.
For a single node that would be simply:
apollo: {
allPalettes: {
query: ALL_PALETTES,
variables: {
skip: 0,
first: PALETTES_PER_PAGE
},
loadingKey: 'loading'
},
However this way I am not getting totalCount. It is working if I duplicate the query:
apollo: {
allPalettes: {
query: ALL_PALETTES,
variables: {
skip: 0,
first: PALETTES_PER_PAGE
},
loadingKey: 'loading'
},
totalCount: {
query: ALL_PALETTES,
variables: {
skip: 0,
first: PALETTES_PER_PAGE
},
loadingKey: 'loading'
}
However this feels kind of wrong. Is there a better way?
Use result hook (see the docs).
Thanks!
Use
resulthook (see the docs).
I got the same question but the link is out of date.
I think the documentation is now here: https://apollo.vuejs.org/api/smart-query.html#options
{
query: gql`...`,
manual: true,
result ({ data, loading }) {
if (!loading) {
this.items = data.items
}
},
}
If I get it correctly, items should also manually be initialized in the data hook.
buen d铆a, hace algunos d铆as he estado trabajando con vue, laravel y apollo y me encontrado con el siguiente problema.
estoy trantando de hacer un OrderBy en mi consulta Graphql y hasta el momento todo funciona a nivel Graphql Playground
pero cuando quiero implementarlo con vue y apollo no he podido.
adjunto mi codigo quiza alguien pueda ayudarme.


a nivel graphql si he podido devolver el OrderBy, pero a nivel de vue aun no logro conseguirlo. quiza alguien pueda ayudarme. saludos
Most helpful comment
Use
resulthook (see the docs).