Skip to content
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

$apolloData is empty when using async data and context.app.apolloProvider.defaultClient.query #478

Closed
weAllHave opened this issue Jan 2, 2019 · 1 comment

Comments

@weAllHave
Copy link

weAllHave commented Jan 2, 2019

I am using NuxtJS and Vue Apollo.

In order to preload my data to have it ready for SEO, I am using the following code.

const buildQuery = route => {
    return {
      query: postGQL,

      fetchPolicy: 'network-only',

      variables: {
        slug: route.params.slug
      }
    }
  }

async asyncData(context) {
      const data = await context.app.apolloProvider.defaultClient.query(buildQuery(context.route))

      return {post: data.data.post}
    }

I am able to load the post correctly, the problem is that $apolloData is empty. When I have a mutation that changes a post, then

store.writeQuery({query: postGQL, variables, data})

will not update it.

I understand that asyncData returns the post in my data and has nothing to do with apollo. How can I include post to $apolloData like when doing something like this:

apollo: { forumQuestion: forumQuestionQuery() }

Here is a screenshot: https://imgur.com/a/GMkaLHJ

@Akryum
Copy link
Member

Akryum commented Jan 9, 2019

See #469

@Akryum Akryum closed this as completed Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants