import { Component, OnInit } from '@angular/core';
import { Pizza, ListPizzaGQL } from 'src/generated/graphql';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';


@Component({
  selector: 'app-pizza-list',
  templateUrl: './pizza-list.component.html',
  styleUrls: ['./pizza-list.component.scss']
})
export class PizzaListComponent implements OnInit {


  displayedColumns: string[] = [
    'id',
    'name',
  ];

  pizzas: Observable<Pizza[]>;

  constructor(listPizza: ListPizzaGQL) {
    this.pizzas = listPizza
    .watch()
    .valueChanges
    .pipe(map(result => result.data.listPizza as Pizza[]));
  }

  ngOnInit(): void {
  }

}
