Exemplo n.º 1
0
        public StoreManagerQuery()
        {
            ItemsFacade itemsFacade = new ItemsFacade();

            Name = "Query";

            Field <ItemType>(
                name: "item",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                return(itemsFacade.GetItemById(id));
            }
                );

            Field <ListGraphType <ItemType> >(
                name: "items",
                resolve: context =>
            {
                return(itemsFacade.GetItems());
            }
                );
        }
        public ItemType()
        {
            ItemsFacade facade = new ItemsFacade();

            Name = "Item";
            Field(h => h.Id).Description("The id of the item.");
            Field(h => h.Name).Description("The name of the item.");
            Field(h => h.Price).Description("The Price of the item.");
            Field(h => h.Tax).Description("The Tax percentage of the item.");
            Field <ListGraphType <PackingType> >(
                "packings",
                resolve: context =>
            {
                var id = context.GetArgument <int>("id");
                return(facade.GetPackingsById(id));
            }
                );
        }
Exemplo n.º 3
0
        public StoreManagerMutation()
        {
            ItemsFacade itemsFacade = new ItemsFacade();

            Name = "Mutation";

            Field <ItemType>(
                name: "createItem",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ItemInputType> > {
                Name = "item"
            }
                    ),
                resolve: context =>
            {
                var item = context.GetArgument <Item>("item");
                return(itemsFacade.AddItem(item));
            }
                );
        }