1// Suppose our profile query took an avatar size
2const CurrentUserForProfile = gql`
3 query CurrentUserForProfile($avatarSize: Int!) {
4 currentUser {
5 login
6 avatar_url(avatarSize: $avatarSize)
7 }
8 }
9`;
10
11@Component({
12 template: `
13 Login: {{currentUser?.profile}}
14 `,
15})
16class ProfileComponent implements OnInit, OnDestroy {
17 currentUser: any;
18 private querySubscription: Subscription;
19 ngOnInit() {
20 this.querySubscription = this.apollo
21 .watchQuery({
22 query: CurrentUserForProfile,
23 variables: {
24 avatarSize: 100,
25 },
26 })
27 .valueChanges.subscribe(({data}) => {
28 this.currentUser = data.currentUser;
29 });
30 }
31 ngOnDestroy() {
32 this.querySubscription.unsubscribe();
33 }
34}