When to use watchQuery or query in Apollo-Angular?

18,795

query is something you just query for once, you can consider it as an equivalent of GET.

watchQuery is something you constantly keep a watch on query, whenever that query will be refetched or the data related to that query is changed from anywhere else, this method will keep on emitting the updated data.

It's really simple, you can read the docs here.

Share:
18,795

Related videos on Youtube

yussenn
Author by

yussenn

Updated on June 05, 2022

Comments

  • yussenn
    yussenn almost 2 years

    I am using a watchQuery or query in Apollo-Angular (graphql)

    How is the logic and difference of the watchQuery and query

  • Paul Razvan Berg
    Paul Razvan Berg over 4 years
    What is the difference between watchQuery and subscriptions?
  • chris
    chris almost 4 years
    @PaulRazvanBerg good question since this is causing a lot of confusion. watchQuery will continue to emit results, as long as this data changes in Apollo's cache memory store. Subscriptions will emit results based on changes/events from the server side.
  • writofmandamus
    writofmandamus over 3 years
    Broken link now