コード例 #1
0
ファイル: Mutation.cs プロジェクト: ygorneves10/wish-list
        public Mutation(IWishListService wishListService)
        {
            Name = "Mutation";

            Field <IntGraphType>(
                "addToList",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ListItemInputType> > {
                Name = "listItem"
            },
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "shopperId"
            },
                    new QueryArgument <StringGraphType> {
                Name = "name"
            },
                    new QueryArgument <BooleanGraphType> {
                Name = "public"
            }
                    ),
                resolve: context =>
            {
                var listItem     = context.GetArgument <ListItem>("listItem");
                string shopperId = context.GetArgument <string>("shopperId");
                string listName  = context.GetArgument <string>("name");
                bool isPublic    = context.GetArgument <bool>("public");

                return(wishListService.SaveItem(listItem, shopperId, listName, isPublic));
            });

            Field <BooleanGraphType>(
                "removeFromList",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            },
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "shopperId"
            },
                    new QueryArgument <StringGraphType> {
                Name = "name"
            }
                    ),
                resolve: context =>
            {
                int id           = context.GetArgument <int>("id");
                string shopperId = context.GetArgument <string>("shopperId");
                string listName  = context.GetArgument <string>("name");

                return(wishListService.RemoveItem(id, shopperId, listName));
            });
        }