public RoomMutation(IRoomService roomService)
        {
            Name        = "RoomMutation";
            Description = "这里主要包含了修改房间状态等功能";

            FieldAsync <BooleanGraphType>(
                "changeRoomStatus",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "roomId"
            },
                    new QueryArgument <NonNullGraphType <RoomStatusEnum> > {
                Name = "status"
            }
                    ),
                resolve: async context =>
            {
                var roomId = context.GetArgument <int>("roomId");
                var status = context.GetArgument <RoomStatus>("status");
                var userId = UserHelpers.GetUserIdFromContext(context.UserContext);

                return(await roomService.ChangeRoomStatus(roomId, userId, status));
            }).AuthorizeWith(Policy.WaiterPolicy);

            FieldAsync <BooleanGraphType>(
                "deleteRoom",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "roomId"
            }
                    ),
                resolve: async context =>
            {
                var roomId = context.GetArgument <int>("roomId");
                return(await roomService.DeleteRoomById(roomId));
            }
                ).AuthorizeWith(Policy.AdminPolicy);

            FieldAsync <BooleanGraphType>(
                "createRoom",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <RoomInputType> > {
                Name = "room"
            }
                    ),
                resolve: async context =>
            {
                var room = context.GetArgument <Room>("room");
                return(await roomService.AddRoom(room));
            }
                ).AuthorizeWith(Policy.AdminPolicy);

            FieldAsync <BooleanGraphType>(
                "updateRoom",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "roomId"
            },
                    new QueryArgument <NonNullGraphType <RoomInputType> > {
                Name = "room"
            }
                    ),
                resolve: async context =>
            {
                var room   = context.GetArgument <Room>("room");
                var roomId = context.GetArgument <int>("roomId");
                room.Id    = roomId;

                return(await roomService.UpdateRoomInfo(room));
            }
                ).AuthorizeWith(Policy.AdminPolicy);
        }
        public UserMutation(IUserService userService)
        {
            Name        = "UserMutation";
            Description = "主要包含了用户注册等功能";

            FieldAsync <BooleanGraphType>(
                "newWaiter",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <UserInputType> > {
                Name = "user"
            }
                    ),
                resolve: async context =>
            {
                var user = context.GetArgument <LoginUser>("user");

                if (user == null || user.Username == null || user.Password == null)
                {
                    throw new ExecutionError("bad username or password input");
                }

                string username = user.Username.Trim();
                string password = user.Password.Trim();

                if (username == "" || password == "")
                {
                    throw new ExecutionError("bad username or password input");
                }

                return(await userService.NewWaiter(user.Username, user.Password));
            });

            FieldAsync <BooleanGraphType>(
                "changeUserPassword",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <UserInputType> > {
                Name = "user"
            }
                    ),
                resolve: async context =>
            {
                var user = context.GetArgument <LoginUser>("user");

                if (user == null || user.Username == null || user.Password == null)
                {
                    throw new ExecutionError("bad username or password input");
                }

                string username = user.Username.Trim();
                string password = user.Password.Trim();

                if (username == "" || password == "")
                {
                    throw new ExecutionError("bad username or password input");
                }

                return(await userService.ChangeUserPassword(username, password));
            });

            FieldAsync <BooleanGraphType>(
                "deleteUser",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "deleteId"
            }
                    ),
                resolve: async context =>
            {
                var userId   = UserHelpers.GetUserIdFromContext(context.UserContext);
                var deleteId = context.GetArgument <int>("deleteId");
                return(await userService.DeleteUser(userId, deleteId));
            });
        }