2

I'm working on Apollo pub-sub using examples from GitHunt-React and GitHunt-API. My subscription resolver is successfully firing when a new record is added to the database it is watching. Now I need to connect my client to the results being sent by the pub-sub resolver.

In GitHunt-React, CommentsPage.js, I see this:

subscribe(repoName, updateCommentsQuery) {
    [.....]
}

Where is updateCommentsQuery declared and how is it being passed to subscribe?

VikR
  • 4,818
  • 8
  • 51
  • 96
  • GitHunt seems to be very very dead now. Not sure what happened to it. These are the remaining links I can find. https://s3.amazonaws.com/apollo-docs-1.x/example-schema.html / https://web.archive.org/web/20180722090310/https://github.com/apollographql/GitHunt-React – icc97 Oct 04 '22 at 09:48
  • You can find the various forks here: https://github.com/white-ubuntu/GitHunt/network/members – icc97 Oct 04 '22 at 12:29

1 Answers1

3

It's passed in as an argument. This is because subscribing and re-subscribing currently has to happen manually when props change: https://github.com/apollostack/GitHunt-React/blob/9b2cc222ef18ee4f89fd4bae3da0a4c0f61b2bb8/ui/routes/CommentsPage.js#L29

But ideally in future Apollo Client releases it will be easier to manage the subscription lifecycle. It's still a pretty experimental feature and we're figuring out the best way to do it.

stubailo
  • 6,077
  • 1
  • 26
  • 32
  • It's great to have this initial version as reactivity is a big deal for my app! Thanks for the link showing how updateCommentsQuery() is passed in. Where is it declared? – VikR Oct 22 '16 at 22:06
  • I don't see it being defined in CommentsPage.js. – VikR Oct 22 '16 at 22:43
  • Turns out GitHub search is really bad. It's defined here, and is just a rename of `updateQuery`: https://github.com/apollostack/GitHunt-React/blob/9b2cc222ef18ee4f89fd4bae3da0a4c0f61b2bb8/ui/routes/CommentsPage.js#L309 – stubailo Oct 22 '16 at 23:06
  • Note that this link is dead now this is the closest I can find https://web.archive.org/web/20180722090310/https://github.com/apollographql/GitHunt-React – icc97 Oct 04 '22 at 12:24