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

Cache is updating but computed property is not. #384

Open
SethThoburn opened this issue Jan 15, 2021 · 2 comments
Open

Cache is updating but computed property is not. #384

SethThoburn opened this issue Jan 15, 2021 · 2 comments

Comments

@SethThoburn
Copy link

SethThoburn commented Jan 15, 2021

My view fetches the needed data, including a list of comments in the model when it loads.

  @queryManager apollo;

  setupController(controller, model) {
    controller.set('approved_comments', model.commentSet.edges.filter(comment => {
      return comment.node.approved == true;
    }))
    controller.set('unapproved_comments', model.commentSet.edges.filter(comment => {
      return comment.node.approved == false;
    }))
  }
  
  async model(params) {
    let variables = { id: params.business_id };
    return this.apollo.watchQuery({ query, variables }, 'business')
  }

Those comments are passed to the controller on two properties which are tracked:

@tracked approved_comments;
@tracked unapproved_comments;

In that controller, an action runs a mutation which modifies some of those comments, and returns the modified comment. I see that the comment is updated in the apollo cache, but the ember tracked properties do not seem to update.
The docs don't have any examples of using a watch query in a model.

@christophermlne
Copy link
Contributor

christophermlne commented Jan 16, 2021 via email

@SethThoburn
Copy link
Author

I am fetching the ID, the cache updates but the UI does not.

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