Esempio n. 1
0
        public HumanType(CharacterRepository repository)
        {
            Name = "Human";

            Interface <CharacterType>();

            Field <NonNullGraphType <IdGraphType> >(
                "id",
                resolve: ctx => ctx.Source.Id);
            Field(t => t.Name, nullable: true);
            Field <ListGraphType <CharacterType> >(
                "friends",
                resolve: context => SharedResolvers.GetCharacter(context.Source, repository));
            Field <ListGraphType <EpisodeType> >(
                "appearsIn",
                resolve: ctx => ctx.Source.AppearsIn);
            Field(t => t.HomePlanet, nullable: true);
            Field <FloatGraphType>(
                "height",
                arguments: new QueryArguments(
                    new QueryArgument <UnitType> {
                Name = "unit"
            }),
                resolve: context => SharedResolvers.GetHeight(context.GetArgument <Unit?>("unit"), context.Source));

            FieldAsync <StringGraphType>(
                "nameHash",
                resolve: async context => await SharedResolvers.GetNameHashAsync(context.Source));

            FieldAsync <StringGraphType>(
                "nameDelayed",
                resolve: async context => await SharedResolvers.GetNameDelayedAsync(context.Source));
        }
Esempio n. 2
0
        public DroidType(CharacterRepository repository)
        {
            Name = "Droid";

            Interface <CharacterType>();

            Field <NonNullGraphType <IdGraphType> >(
                "id",
                resolve: ctx => ctx.Source.Id);
            Field(t => t.Name, nullable: true);
            Field <ListGraphType <CharacterType> >(
                "friends",
                resolve: context => SharedResolvers.GetCharacter(context.Source, repository));
            Field <ListGraphType <EpisodeType> >(
                "appearsIn",
                resolve: ctx => ctx.Source.AppearsIn);
            Field(t => t.PrimaryFunction, nullable: true);
            Field <FloatGraphType>(
                "height",
                arguments: new QueryArguments(
                    new QueryArgument <UnitType> {
                Name = "unit"
            }),
                resolve: context => SharedResolvers.GetHeight(context.GetArgument <Unit?>("unit"), context.Source));
        }
Esempio n. 3
0
        public HumanType(CharacterRepository repository)
        {
            Name = "Human";

            Interface <CharacterType>();

            Field(t => t.Id).Type(new NonNullGraphType <IdGraphType>());
            Field(t => t.Name, nullable: true);
            Field <ListGraphType <CharacterType> >(
                "friends",
                resolve: context => SharedResolvers.GetCharacter(context.Source, repository));
            Field(t => t.AppearsIn).Type(new ListGraphType <EpisodeType>());
            Field <FloatGraphType>(
                "height",
                arguments: new QueryArguments(
                    new QueryArgument <UnitType> {
                Name = "unit"
            }),
                resolve: context => SharedResolvers.GetHeight(context.GetArgument <Unit?>("unit"), context.Source));
        }