コード例 #1
0
ファイル: HumanType.cs プロジェクト: bolivernoguera/starwars
        public HumanType(StarWarsData data)
        {
            Name = "Human";

            Field <NonNullGraphType <IdGraphType> >("id", "The id of the human.");

            Field(h => h.Name, nullable: false).Description("The name of the human.");

            Field(h => h.Mass, nullable: false).Description("Mass in kilograms, or null if unknown");

            Field <NonNullGraphType <FloatGraphType> >(
                "height",
                arguments: new QueryArguments(
                    new QueryArgument <HeighEnum> {
                Name = "unit", Description = "Height in the preferred unit, default is meters", DefaultValue = LengthUnit.METER
            }
                    ),
                resolve: context => data.GetHeighOrLenght(context.GetArgument <LengthUnit>("unit", LengthUnit.METER), context.Source.Height)
                );


            Field <ListGraphType <CharacterInterface> >(
                "friends",
                resolve: context => data.GetFriends(context.Source)
                );

            Field <ListGraphType <StarShipType> >(
                "starships",
                resolve: context => context.Source.Starships
                );

            Field <NonNullGraphType <ListGraphType <NonNullGraphType <EpisodeEnum> > > >("appearsIn", "Which movie they appear in.");

            Interface <CharacterInterface>();
        }
コード例 #2
0
        public HumanType(StarWarsData data)
        {
            Name = "Human";

            Field(h => h.Id).Description("The id of the human.");
            Field(h => h.Name, nullable: true).Description("The name of the human.");

            Field <ListGraphType <CharacterInterface> >(
                "friends",
                resolve: context => data.GetFriends(context.Source)
                );

            Connection <CharacterInterface>()
            .Name("friendsConnection")
            .Description("A list of a character's friends.")
            .Bidirectional()
            .Resolve(context =>
            {
                return(context.GetPagedResults <Human, StarWarsCharacter>(data, context.Source.Friends));
            });

            Field <ListGraphType <EpisodeEnum> >("appearsIn", "Which movie they appear in.");

            Field(h => h.HomePlanet, nullable: true).Description("The home planet of the human.");

            Interface <CharacterInterface>();
        }
コード例 #3
0
        public DroidType(StarWarsData data)
        {
            Name        = "Droid";
            Description = "A mechanical creature in the Star Wars universe.";

            Field(d => d.Id).Description("The id of the droid.");
            Field(d => d.Name, nullable: true).Description("The name of the droid.");

            Field <ListGraphType <CharacterInterface> >(
                "friends",
                resolve: context => {
                // simulate loading
                // await Task.Delay(1000);
                return(data.GetFriends(context.Source));
            }
                );

            Connection <CharacterInterface>()
            .Name("friendsConnection")
            .Description("A list of a character's friends.")
            .Bidirectional()
            .Resolve(context => context.GetPagedResults <Droid, StarWarsCharacter>(data, context.Source.Friends));

            Field <ListGraphType <EpisodeEnum> >("appearsIn", "Which movie they appear in.");
            Field(d => d.PrimaryFunction, nullable: true).Description("The primary function of the droid.");

            Interface <CharacterInterface>();
        }
コード例 #4
0
        public DroidType()
        {
            var data = new StarWarsData();

            Name = "Droid";
            Field <NonNullGraphType <StringGraphType> >("id", "The id of the droid.");
            Field <NonNullGraphType <StringGraphType> >("name", "The name of the droid.");
            Field <ListGraphType <CharacterInterface> >(
                "friends",
                resolve: context => data.GetFriends(context.Source as StarWarsCharacter)
                );
            Interface <CharacterInterface>();
            IsTypeOf = value => value is Droid;
        }
コード例 #5
0
        public DroidType()
        {
            var data = new StarWarsData();

            Name = "Droid";

            Field("id", "The id of the droid.", NonNullGraphType.String);
            Field("name", "The name of the droid.", NonNullGraphType.String);
            Field<ListGraphType<CharacterInterface>>(
                "friends",
                resolve: context => data.GetFriends(context.Source as StarWarsCharacter)
            );

            Interface<CharacterInterface>();
        }
コード例 #6
0
ファイル: HumanType.cs プロジェクト: ghstahl/Azure-Api-Proofs
        public HumanType(StarWarsData data)
        {
            Name = "Human";

            Field(h => h.Id).Description("The id of the human.");
            Field(h => h.Name, nullable: true).Description("The name of the human.");

            Field <ListGraphType <CharacterInterface> >(
                "friends",
                resolve: context => data.GetFriends(context.Source)
                );
            Field <ListGraphType <EpisodeEnum> >("appearsIn", "Which movie they appear in.");

            Field(h => h.HomePlanet, nullable: true).Description("The home planet of the human.");

            Interface <CharacterInterface>();
        }
コード例 #7
0
        public DroidType(StarWarsData data)
        {
            Name        = "Droid";
            Description = "A mechanical creature in the Star Wars universe.";

            Field(d => d.Id).Description("The id of the droid.");
            Field(d => d.Name, nullable: true).Description("The name of the droid.");

            Field <ListGraphType <CharacterInterface> >(
                "friends",
                resolve: context => data.GetFriends(context.Source)
                );
            Field <ListGraphType <EpisodeEnum> >("appearsIn", "Which movie they appear in.");
            Field(d => d.PrimaryFunction, nullable: true).Description("The primary function of the droid.");

            Interface <CharacterInterface>();
        }
コード例 #8
0
ファイル: HumanType.cs プロジェクト: mwatts/graphql-dotnet
        public HumanType(StarWarsData data)
        {
            Name = "Human";

            Field<NonNullGraphType<StringGraphType>>("id", "The id of the human.");
            Field<StringGraphType>("name", "The name of the human.");
            Field<ListGraphType<CharacterInterface>>(
                "friends",
                resolve: context => data.GetFriends(context.Source as StarWarsCharacter)
            );
            Field<ListGraphType<EpisodeEnum>>("appearsIn", "Which movie they appear in.");
            Field<StringGraphType>("homePlanet", "The home planet of the human.");

            Interface<CharacterInterface>();

            IsTypeOf = value => value is Human;
        }
コード例 #9
0
        public HumanType(StarWarsData data)
        {
            Name = "Human";

            Field <NonNullGraphType <StringGraphType> >("id", "The id of the human.");
            Field <StringGraphType>("name", "The name of the human.");
            Field <ListGraphType <CharacterInterface> >(
                "friends",
                resolve: context => data.GetFriends(context.Source as StarWarsCharacter)
                );
            Field <ListGraphType <EpisodeEnum> >("appearsIn", "Which movies they appear in.");
            Field <StringGraphType>("homePlanet", "The home planet of the human.");

            Interface <CharacterInterface>();

            IsTypeOf = value => value is Human;
        }
コード例 #10
0
ファイル: DroidType.cs プロジェクト: mwatts/graphql-dotnet
        public DroidType(StarWarsData data)
        {
            Name = "Droid";
            Description = "A mechanical creature in the Star Wars universe.";

            Field<NonNullGraphType<StringGraphType>>("id", "The id of the droid.");
            Field<StringGraphType>("name", "The name of the droid.");
            Field<ListGraphType<CharacterInterface>>(
                "friends",
                resolve: context => data.GetFriends(context.Source as StarWarsCharacter)
            );
            Field<ListGraphType<EpisodeEnum>>("appearsIn", "Which movie they appear in.");
            Field<StringGraphType>("primaryFunction", "The primary function of the droid.");

            Interface<CharacterInterface>();

            IsTypeOf = value => value is Droid;
        }
コード例 #11
0
ファイル: DroidType.cs プロジェクト: rhueller/graphql-dotnet
        public DroidType(StarWarsData data)
        {
            Name        = "Droid";
            Description = "A mechanical creature in the Star Wars universe.";

            Field <NonNullGraphType <StringGraphType> >("id", "The id of the droid.");
            Field <StringGraphType>("name", "The name of the droid.");
            Field <ListGraphType <CharacterInterface> >(
                "friends",
                resolve: context => data.GetFriends(context.Source as StarWarsCharacter)
                );
            Field <ListGraphType <EpisodeEnum> >("appearsIn", "Which movie they appear in.");
            Field <StringGraphType>("primaryFunction", "The primary function of the droid.");

            Interface <CharacterInterface>();

            IsTypeOf = value => value is Droid;
        }
コード例 #12
0
    public HumanType(StarWarsData data)
    {
        Name = "Human";

        Field <NonNullGraphType <StringGraphType> >("id", "The id of the human.", resolve: context => context.Source.Id);
        Field <StringGraphType>("name", "The name of the human.", resolve: context => context.Source.Name);

        Field <ListGraphType <CharacterInterface> >("friends", resolve: context => data.GetFriends(context.Source));

        Connection <CharacterInterface>()
        .Name("friendsConnection")
        .Description("A list of a character's friends.")
        .Bidirectional()
        .Resolve(context => context.GetPagedResults <Human, StarWarsCharacter>(data, context.Source.Friends));

        Field <ListGraphType <EpisodeEnum> >("appearsIn", "Which movie they appear in.");

        Field <StringGraphType>("homePlanet", "The home planet of the human.", resolve: context => context.Source.HomePlanet);

        Interface <CharacterInterface>();
    }
コード例 #13
0
    public DroidType(StarWarsData data)
    {
        Name        = "Droid";
        Description = "A mechanical creature in the Star Wars universe.";

        Field <NonNullGraphType <StringGraphType> >("id", "The id of the droid.", resolve: context => context.Source.Id);
        Field <StringGraphType>("name", "The name of the droid.", resolve: context => context.Source.Name);

        Field <ListGraphType <CharacterInterface> >("friends", resolve: context => data.GetFriends(context.Source));

        Connection <CharacterInterface>()
        .Name("friendsConnection")
        .Description("A list of a character's friends.")
        .Bidirectional()
        .Resolve(context => context.GetPagedResults <Droid, StarWarsCharacter>(data, context.Source.Friends));

        Field <ListGraphType <EpisodeEnum> >("appearsIn", "Which movie they appear in.");
        Field <StringGraphType>("primaryFunction", "The primary function of the droid.", resolve: context => context.Source.PrimaryFunction);

        Interface <CharacterInterface>();
    }
コード例 #14
0
 public Connection <ICharacter> Friends(int?first = null, string after = null, int?last = null, string before = null) =>
 _data.GetFriends(_dto).AsCharacters(_data).ToConnection(x => x.Id, first, after, last, before);