
import gql from "graphql-tag";

export const pizzaSchema = gql`
  type Pizza {
    id: ID!
    name: String!
    toppings: [Topping!]!
  }

  type Topping {
    id: ID!
    name: String!
  }

  type Query {
    getPizzaById(pizzaId: ID!): Pizza!
    getToppingById(toppingId: ID!): Topping!
    getPizzaByName(pizzaName: ID!): Pizza!
    getToppingByName(toppingName: ID!): Topping!
    listPizza: [Pizza]!
    listTopping: [Topping]!
  }

  input ChangePizzaDto {
    name: String!
    toppingIds: [ID]!
  }

  input ChangeToppingDto {
    name: String!
  }

  type Mutation {
    createPizza(createPizzaDto: ChangePizzaDto): Pizza!
    updatePizza(pizzaId: ID!, updatedPizzaDto: ChangePizzaDto!): Pizza!
    createTopping(createToppingDto: ChangeToppingDto): Topping!
    updateTopping(toppingId: ID!, updatedToppingDto: ChangeToppingDto!): Topping!
    deleteTopping(toppingId: ID!): Topping!
    deletePizza(pizzaId: ID!): Pizza!
  }

  type Subscription {
    pizzasChanged: [Pizza]!
    toppingsChanged: [Topping]!
  }
`;
