aerogear / offix

GraphQL Offline Client and Server
https://offix.dev
Apache License 2.0
758 stars 45 forks source link

valueChanges not on query? #425

Closed KyleBrost closed 4 years ago

KyleBrost commented 4 years ago

When trying to convert from the regualr apollo client to the offix offline client a simple watchQuery does not work:

this.client.watchQuery<ScheduleQueryResponse>({
  query: SCHEDULE_EVENT_QUERY_ALL,
  variables: {
    eventDate: eventDate_,
    resourceId: resourceId_,
  }
}).valueChanges.subscribe( ({data,loading}) => {

    this.loading = loading;
    this.todos = data.todos;
});

I get an error that "valueChanges" does not exist. I'm wondering why if it's based on the same client and how do I get the same functionality of the valueChanges?

wtrocki commented 4 years ago

Offix client is using Apollo client. valueChanges comes from Apollo Angular which is a wrapper around Apollo Client.

To quote docs:


The `watchQuery` method returns a `QueryRef` object which has the `valueChanges`
property that is an `Observable`.

I think that watch query has already observable so valueChanges can be ignored

https://codesandbox.io/s/apollo-client-watch-query-2vzo5