Created
November 15, 2018 11:04
-
-
Save kamilkisiela/137c18821a23818c13b2beb68826a636 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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