public CharacterQLType(IFactionRepository factionRepository, ICharacterRepository characterRepository, ICharacterTypeRepository characterTypeRepository, ICharacterGroupRepository characterGroupRepository, IEpisodeRepository episodeRepository, IStarshipRepository starshipRepository)
 {
     Field(x => x.Id).Description("Character id.");
     Field(x => x.CharacterName, nullable: false).Description("Character name.");
     Field(x => x.CharacterTypeID, nullable: true).Description("Character Type ID.");
     Field <CharacterTypeQLType>("CharacterType", "Character Type",
                                 resolve: context => characterTypeRepository.GetCharacterType(context.Source.CharacterTypeID)
                                 );
     Field(x => x.CharacterGroupID, nullable: false).Description("Character Group ID.");
     Field <CharacterGroupQLType>("CharacterGroup", "Character Group",
                                  arguments: new QueryArguments(new QueryArgument <IntGraphType>()
     {
         Name        = "id",
         Description = "Character Group ID."
     }),
                                  resolve: context => characterGroupRepository.GetCharacterGroup(context.Source.CharacterGroupID)
                                  );
     Field <ListGraphType <EpisodeQLType> >("AppersIn_Episodes", "character appears in following Episodes",
                                            arguments: new QueryArguments(new QueryArgument <IntGraphType>()
     {
         Name        = "id",
         Description = "Character ID."
     }),
                                            resolve: context => episodeRepository.GetEpisodeByCharacterId(context.Source.Id)
                                            );
     Field <ListGraphType <StarshipQLType> >("Starships", "character Starships",
                                             resolve: context => starshipRepository.GetStarshipsByCharacterId(context.Source.Id)
                                             );
     Field(x => x.HomePlanet, nullable: false).Description("Character HomePlanet.");
     Field(x => x.Purpose, nullable: true).Description("Character Purpose.");
     Field(x => x.FactionID, nullable: true).Description("Character FactionID.");
     Field <FactionQLType>("Faction", "character Faction",
                           resolve: context => factionRepository.GetFaction(context.Source.FactionID)
                           );
     Field(x => x.ImageUrl, nullable: false).Description("Character ImageUrl.");
     //    (
     //    "Faction",
     //    resolve: context => factionRepository.GetFactionByID(context.Source.).Result.ToList()
     //);
 }
Beispiel #2
0
        public StarWarsQuery(ICharacterRepository characterRepository, IFactionRepository factionRepository, IEpisodeRepository episodeRepository, ICharacterGroupRepository characterGroupRepository, ICharacterTypeRepository characterTypeRepository, IStarshipRepository starshipRepository)
        {
            #region Faction
            Field <ListGraphType <FactionQLType> >(
                "factions",
                //arguments: new QueryArguments(
                //    new QueryArgument<IntGraphType> { Name = "id", Description = "faction id" }
                //),
                resolve: context => factionRepository.GetFaction().Result
                );

            Field <FactionQLType>(
                "faction",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id", Description = "faction id"
            }
                    ),
                resolve: context => factionRepository.GetFaction(context.GetArgument <int>("id")).Result
                );
            #endregion

            #region Episode
            Field <EpisodeQLType>(
                "episode",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id", Description = "episode id"
            }
                    ),
                resolve: context => episodeRepository.GetEpisode(context.GetArgument <int>("id")).Result
                );
            Field <ListGraphType <EpisodeQLType> >(
                "episodes",
                //arguments: new QueryArguments(
                //    new QueryArgument<NonNullGraphType<IntGraphType>> { Name = "id", Description = "episode id" }
                //),
                resolve: context => episodeRepository.GetEpisode().Result
                );
            #endregion

            #region Character
            Field <ListGraphType <CharacterQLType> >(
                "characters",
                //arguments: new QueryArguments(
                //    new QueryArgument<NonNullGraphType<IntGraphType>> { Name = "id", Description = "character id" }
                //),
                resolve:
                context => characterRepository.GetCharacter().Result
                );

            Field <CharacterQLType>(
                "character",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id", Description = "character id"
            }
                    ),
                resolve:
                context => characterRepository.GetCharacter(context.GetArgument <int>("id")).Result
                );
            #endregion

            #region Starship
            Field <StarshipQLType>(
                "starships",
                //arguments: new QueryArguments(
                //    new QueryArgument<NonNullGraphType<IntGraphType>> { Name = "id", Description = "starship id" }
                //),
                resolve: context => starshipRepository.GetStarship().Result
                );

            Field <StarshipQLType>(
                "starship",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id", Description = "starship id"
            }
                    ),
                resolve: context => starshipRepository.GetStarship(context.GetArgument <int>("id")).Result
                );
            #endregion
        }