Skip to content

Instantly share code, notes, and snippets.

@kamilkisiela
Created November 15, 2018 11:04
Show Gist options
  • Save kamilkisiela/137c18821a23818c13b2beb68826a636 to your computer and use it in GitHub Desktop.
Save kamilkisiela/137c18821a23818c13b2beb68826a636 to your computer and use it in GitHub Desktop.
import { GetPostGQL, Post } from './generated/graphql';
@Component({...})
export class PostComponent {
@Input() postId: string;
post: Observable<Post>;
constructor(
private getPostGQL: GetPostGQL
) {}
ngOnInit() {
this.post = this.getPostGQL
.watch({ id: this.postId })
.valueChanges
.pipe(
map(result => result.data.post)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment