- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 311
 
Refetch, polling, loading, basically all #19
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
Conversation
| 
           @jboothe So here's an idea you're interested in :)  | 
    
| 
           While I was working on GitHunt for Angular2 I added few new features. @stubailo You might be interested in the progress 🚀 @Urigo There are still no tests for that features so for now it's just a sort of concept rather then "ready to go" thing. So what's new?
 Result of a query: {
  loading: boolean
  errors: any[]
  refetch: Function
  unsubscribe: Function
  stopPolling: Function
  startPolling: Function
  ...
  [string]: any // query name as a key and result of that query as value 
  // (an example: `feed`: [{id: 1}, {id: 3}, {id: 5}])
}An example:@Component({
  selector: 'app',
  templateUrl: '/app.html'
})
@Apollo({
  client,
  queries(context) {
    return {
      data:  {
        query: gql`
          query Feed($type: FeedType!) {
            currentUser {
              login
            }
            feed(type: $type) {
              createdAt
              id
            }
          }
        `,
        variables: {
          type: context.type ? context.type.toUpperCase() : 'TOP'
        },
        forceFetch: true,
      }
    };
  }
})
class App {}<loading *ngIf="data.loading"></loading>
<feed-entry
  *ngIf="!data.loading" 
  *ngFor="let entry of data.feed" 
  [entry]="entry"
  [currentUser]="data.currentUser"
  (onVote)="onVote($event)">
</feed-entry> | 
    
| 
           And a working implementation of it (one issue with additional record in ngFor, but that's all) https://github.com/kamilkisiela/GitHunt-angular2/commit/a0593e4afb8c8bb402cb0f04ab26b4437b3a1017  | 
    
What is new? Mostly the return value of mapped query It now contains: * errors - of subsription * loading - boolean with status * unsubscribe - just like the result of watchQuery * refetch * stopPolling * startPolling forceFetch, returnPartialData and pollInterval have been added to mapped queries options which are now exactly the same as watchQuery options
| 
           After releasing this, GitHunt for Angular2 will be practically ready.  | 
    
| 
           Thanks a lot! @kamilkisiela  | 
    
| 
           @helfer It's always a pleasure to help!  | 
    
Update usage of networkInterface for latest apollo-client
An example of usage:
UPDATE - see that comment
Outdated now