How to implement a working Graphql query in Vue with Apollo?
It seems vue-apollo
expects to find under data
in the response sent by the server a key matching what you set in your apollo definition. Try replacing
apollo: { allPrograms: { ... }}
by
apollo: { viewer: { ... }}
and your error goes away, but that's probably not what you want.
Instead, add an update
option to your query definition to alter the data set. Assuming you want the content of allPrograms
:
apollo: { allPrograms: { query: allPrograms, loadingKey: 'loading', update: function(data) { return data.viewer.allPrograms; // or if you just want the leaf objects return data.viewer.allPrograms.edges.map(function(edge) { return edge.node; }); } },}