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>(); }
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>(); }
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>(); }
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; }
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>(); }
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>(); }
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>(); }
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; }
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; }
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; }
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; }
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>(); }
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>(); }
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);