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

How to use gqlSubscribe #17

Open
boboci9 opened this issue Jan 22, 2019 · 0 comments
Open

How to use gqlSubscribe #17

boboci9 opened this issue Jan 22, 2019 · 0 comments

Comments

@boboci9
Copy link

boboci9 commented Jan 22, 2019

Hi,

I am trying to get a refetch of the data that has been changed by a mutation but I can't get the query to rerun.
If I call the gqlSubscribe with the same query and variables I see the logs from the query reaching the new data but the gqlQuery is not rerun.
I couldn't find it in the docs how could I use the gqlSubscribe in a situation like this

Template.patientInfo.created = function() {
  this.member = new ReactiveVar(false);
  Session.set("showLoadingPatientForm", false);

  tempInst = this;
  this.autorun(function() {
    console.log(Session.get("showLoadingPatientForm"));
    if (Session.get("showLoadingPatientForm")) console.log("reload");
    if (FlowRouter.getParam("id")) {
      let variables = { _id: FlowRouter.getParam("id") };

      console.log("subs",
        Template.instance()
          .gqlSubscribe({
            query: GET_PATIENT,
            variables: variables
          })); // here I can see the query logs reach the new data but the gqlQuery won't run again
      let currentPatient = Template.instance()
        .gqlQuery({
          query: GET_PATIENT,
          fetchPolicy: "no-cache",
          variables: variables
        })
        .get();
      if (currentPatient && currentPatient.patient) {
        tempInst.member.set(currentPatient.patient);
        Session.set("showLoadingPatientForm", false);
      }
    } else {
      tempInst.member.set({});
    }
  });
};
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

1 participant