Exemplo n.º 1
0
        public QueryType(CharacterRepository repository)
        {
            Name        = "Query";
            _repository = repository
                          ?? throw new ArgumentNullException(nameof(repository));

            Field <CharacterType>()
            .Name("hero")
            .Argument <EpisodeType>("episode", "")
            .Resolve(context => _repository.GetHero(context.GetArgument <Episode>("episode")));

            Field <CharacterType>()
            .Name("character")
            .Argument <NonNullGraphType <ListGraphType <NonNullGraphType <IdGraphType> > > >("characterIds", "")
            .Resolve(context => GetCharacter(context.GetArgument <string[]>("characterIds")));

            Field <HumanType>()
            .Name("human")
            .Argument <NonNullGraphType <IdGraphType> >("id", "")
            .Resolve(context => _repository.GetHuman(context.GetArgument <string>("id")));

            Field <DroidType>()
            .Name("human")
            .Argument <NonNullGraphType <IdGraphType> >("id", "")
            .Resolve(context => _repository.GetDroid(context.GetArgument <string>("id")));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Get a particular droid by Id.
 /// </summary>
 /// <param name="id">The Id of the droid.</param>
 /// <returns>The droid.</returns>
 public Droid GetDroid(string id)
 {
     return(_repository.GetDroid(id));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Get a particular droid by Id.
 /// </summary>
 /// <param name="id">The Id of the droid.</param>
 /// <returns>The droid.</returns>
 public Task <Droid> GetDroid(string id)
 {
     return(_repository.GetDroid(id));
 }