Пример #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public CharacterGraphType([FromServices] ICharacterGraphServices characterGraphServices)
        {
            Name        = "Character";
            Description = "Um personagem do mundo de Dragon Ball Z";

            Field(x => x.ID).Name("id");
            Field(x => x.Name).Description("Nome do personagem");
            Field <CharacterKindEnum>("kind", "Raça do personagem");
            Field(x => x.BirthDate).Description("Ano de nascimento do personagem");
            Field <ListGraphType <RelativeGraphType> >("relatives", resolve: context => characterGraphServices.GetRelativesAsync(context.Source.ID)).Description = "Lista de parentes";
        }
Пример #2
0
        public DbzQuery([FromServices] ICharacterGraphServices characterGraphServices)
        {
            Field <CharacterGraphType>(
                "character",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context => characterGraphServices.GetByIDAsync(context.GetArgument <int>("id")));

            Field <ListGraphType <CharacterGraphType> >(
                "characters",
                resolve: context =>
            {
                return(characterGraphServices.GetAllAsync());
            });
        }
Пример #3
0
        public DbzMutation([FromServices] ICharacterGraphServices characterGraphServices)
        {
            this.AuthorizeWith("AdminPolicy");

            Name = "CreateCharacterMutation";

            Field <CharacterGraphType>(
                "createCharacter",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <CharacterGraphInputType> > {
                Name = "character"
            }
                    ),
                resolve: context =>
            {
                var character = context.GetArgument <CharacterModel>("character");
                return(characterGraphServices.CreateAsync(character));
            });
        }