import { arg , fieldResolver , Publisher , pubSub , query , resolver , } from '../../../../' ; import { mutation , root } from '../../../../decorators' ; import { RecipeInput } from './recipe.input' ; import { Recipe } from './recipe.model' ; @ resolver ( of => Recipe ) export class RecipeResolver { constructor ( ) { } @ query ( returns => [ Recipe ] ) async recipes ( ) { return [ ] ; } @ fieldResolver ( ) lowercaseTitle ( @ root ( ) recipe ) { return recipe . title . toLowerCase ( ) ; } @ mutation ( returns => Recipe ) async addRecipe ( @ arg ( 'recipe' ) recipe , @ pubSub ( 'recipeCreated' ) publish ) { const result = new Recipe ( ) ; result . title = recipe . title ; await publish ( result ) ; return result ; } }