Skip to content

Instantly share code, notes, and snippets.

@cgatian
Last active September 9, 2019 19:49
Show Gist options
  • Save cgatian/12530d7ab111b0857374126c3433fafd to your computer and use it in GitHub Desktop.
Save cgatian/12530d7ab111b0857374126c3433fafd to your computer and use it in GitHub Desktop.
import { Component } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { UsersGQL } from '../generated/types.graphql-gen';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
usersName$: Observable<string[]>;
constructor(userNameService: UsersGQL) {
this.usersName$ = userNameService.fetch({}).pipe(
map(result => result.data.users.data.map(user => user.name)),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment