Ejemplo n.º 1
0
 public ProductQuery(IProductsModule productsModule)
 {
     FieldAsync <ListGraphType <ProductType> >("products",
                                               arguments: new QueryArguments(new List <QueryArgument>
     {
         new QueryArgument <IdGraphType>
         {
             Name = "id"
         },
         new QueryArgument <StringGraphType>
         {
             Name = "name"
         },
         new QueryArgument <StringGraphType>
         {
             Name = "description"
         },
         new QueryArgument <DecimalGraphType>
         {
             Name = "price"
         },
         new QueryArgument <DecimalGraphType>
         {
             Name = "stock"
         }
     }),
                                               resolve: async context =>
     {
         var products = await productsModule.ExecuteQueryAsync(new GetAllProductsQuery());
         return(products);
     });
 }
Ejemplo n.º 2
0
 public ProductMutation(IProductsModule productsModule)
 {
     FieldAsync <ProductType>("createProduct",
                              arguments: new QueryArguments(new QueryArgument <NonNullGraphType <CreateProductInputType> > {
         Name = "input"
     }),
                              resolve: async context =>
     {
         var input = context.GetArgument <Product>("input");
         await productsModule.ExecuteCommandAsync(new CreateProductCommand(input));
         return(input);
     });
 }