Ejemplo n.º 1
0
 private void AllField <ResolveType, ModelType>(string fieldName, string resourcePath) where ResolveType : IGraphType
 {
     Field <ListGraphType <ResolveType> >(
         fieldName,
         resolve: context => SWAPI.GetAll <ModelType>(resourcePath)
         );
 }
Ejemplo n.º 2
0
 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));
     }
         );
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 private IEnumerable <Species> ResolveSpecies(ResolveFieldContext <Film> context)
 {
     return(SWAPI.ResolveReferences <Species>(context.Source.Species).GetAwaiter().GetResult());
 }
Ejemplo n.º 5
0
 private IEnumerable <Planet> ResolvePlanets(ResolveFieldContext <Film> context)
 {
     return(SWAPI.ResolveReferences <Planet>(context.Source.Planets).GetAwaiter().GetResult());
 }
Ejemplo n.º 6
0
 private IEnumerable <Person> ResolveCharacters(ResolveFieldContext <Film> context)
 {
     return(SWAPI.ResolveReferences <Person>(context.Source.Characters).GetAwaiter().GetResult());
 }
Ejemplo n.º 7
0
 private IEnumerable <Vehicle> ResolveVehicles(ResolveFieldContext <Film> context)
 {
     return(SWAPI.ResolveReferences <Vehicle>(context.Source.Vehicles).GetAwaiter().GetResult());
 }
Ejemplo n.º 8
0
 private IEnumerable <Person> ResolvePilots(ResolveFieldContext <Starship> context)
 {
     return(SWAPI.ResolveReferences <Person>(context.Source.Pilots).GetAwaiter().GetResult());
 }
Ejemplo n.º 9
0
 private IEnumerable <Film> ResolveFilms(ResolveFieldContext <Starship> context)
 {
     return(SWAPI.ResolveReferences <Film>(context.Source.Films).GetAwaiter().GetResult());
 }
Ejemplo n.º 10
0
 private Planet ResolveHomeworld(ResolveFieldContext <Person> context)
 {
     return(SWAPI.ResolveReference <Planet>(context.Source.Homeworld).GetAwaiter().GetResult());
 }
Ejemplo n.º 11
0
 private IEnumerable <Person> ResolvePeople(ResolveFieldContext <Species> context)
 {
     return(SWAPI.ResolveReferences <Person>(context.Source.People).GetAwaiter().GetResult());
 }
Ejemplo n.º 12
0
 private IEnumerable <Person> ResolveResidents(ResolveFieldContext <Planet> context)
 {
     return(SWAPI.ResolveReferences <Person>(context.Source.Residents).GetAwaiter().GetResult());
 }