Skip to content

Cache is updating but computed property is not. #384

@SethThoburn

Description

@SethThoburn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions