private void AllField <ResolveType, ModelType>(string fieldName, string resourcePath) where ResolveType : IGraphType { Field <ListGraphType <ResolveType> >( fieldName, resolve: context => SWAPI.GetAll <ModelType>(resourcePath) ); }
private void FieldFromID <ResolveType, ModelType>(string fieldName, string resourcePath) where ResolveType : IGraphType { Field <ResolveType>( fieldName, arguments: new QueryArguments( new QueryArgument <IdGraphType> { Name = "id" } ), resolve: context => { var id = context.GetArgument <string>("id"); return(SWAPI.GetByID <ModelType>(resourcePath, id)); } ); }
public List <string> GetStarshipsWithPilots(int minPassengers) { var result = new List <string>(); var ships = SWAPI.Starships(); var shipsContainer = JsonConvert.DeserializeObject <ResultsContainer <Starship> >(ships); foreach (var ship in shipsContainer.results.Where(r => r.pilots.Count > 0 && r.passengers >= minPassengers)) { foreach (var pilotUri in ship.pilots) { var parts = pilotUri.Split(new char[] { '/' }, System.StringSplitOptions.RemoveEmptyEntries); int id; int.TryParse(parts[parts.Length - 1], out id); var pilot = SWAPI.Pilot(id); Pilot objPilot = JsonConvert.DeserializeObject <Pilot>(pilot); result.Add($"{ship.name} - {objPilot.name}"); } } return(result); }
private IEnumerable <Species> ResolveSpecies(ResolveFieldContext <Film> context) { return(SWAPI.ResolveReferences <Species>(context.Source.Species).GetAwaiter().GetResult()); }
private IEnumerable <Planet> ResolvePlanets(ResolveFieldContext <Film> context) { return(SWAPI.ResolveReferences <Planet>(context.Source.Planets).GetAwaiter().GetResult()); }
private IEnumerable <Person> ResolveCharacters(ResolveFieldContext <Film> context) { return(SWAPI.ResolveReferences <Person>(context.Source.Characters).GetAwaiter().GetResult()); }
private IEnumerable <Vehicle> ResolveVehicles(ResolveFieldContext <Film> context) { return(SWAPI.ResolveReferences <Vehicle>(context.Source.Vehicles).GetAwaiter().GetResult()); }
private IEnumerable <Person> ResolvePilots(ResolveFieldContext <Starship> context) { return(SWAPI.ResolveReferences <Person>(context.Source.Pilots).GetAwaiter().GetResult()); }
private IEnumerable <Film> ResolveFilms(ResolveFieldContext <Starship> context) { return(SWAPI.ResolveReferences <Film>(context.Source.Films).GetAwaiter().GetResult()); }
private Planet ResolveHomeworld(ResolveFieldContext <Person> context) { return(SWAPI.ResolveReference <Planet>(context.Source.Homeworld).GetAwaiter().GetResult()); }
private IEnumerable <Person> ResolvePeople(ResolveFieldContext <Species> context) { return(SWAPI.ResolveReferences <Person>(context.Source.People).GetAwaiter().GetResult()); }
private IEnumerable <Person> ResolveResidents(ResolveFieldContext <Planet> context) { return(SWAPI.ResolveReferences <Person>(context.Source.Residents).GetAwaiter().GetResult()); }