Beispiel #1
0
        public StarWarsQuery(StarWarsData data)
        {
            Name = "Query";

            Field <CharacterInterface>("hero", resolve: context => data.GetDroidByIdAsync("3"));
            Field <HumanType>(
                "human",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id", Description = "id of the human"
            }
                    ),
                resolve: context => data.GetHumanByIdAsync(context.GetArgument <string>("id"))
                );

            Func <IResolveFieldContext, string, object> func = (context, id) => data.GetDroidByIdAsync(id);

            Field <DroidType>(
                "droid",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id", Description = "id of the droid"
            }
                    ),
                resolve: context => data.GetDroidByIdAsync(context.GetArgument <string>("id"))
                );
        }
Beispiel #2
0
    public StarWarsQuery(StarWarsData data)
    {
        Name = "Query";

        FieldAsync <CharacterInterface>("hero", resolve: async context => await data.GetDroidByIdAsync("3").ConfigureAwait(false));
        FieldAsync <HumanType>(
            "human",
            arguments: new QueryArguments(
                new QueryArgument <NonNullGraphType <StringGraphType> > {
            Name = "id", Description = "id of the human"
        }
                ),
            resolve: async context => await data.GetHumanByIdAsync(context.GetArgument <string>("id")).ConfigureAwait(false)
            );

        Func <IResolveFieldContext, string, Task <Droid> > func = (context, id) => data.GetDroidByIdAsync(id);

        FieldDelegate <DroidType>(
            "droid",
            arguments: new QueryArguments(
                new QueryArgument <NonNullGraphType <StringGraphType> > {
            Name = "id", Description = "id of the droid"
        }
                ),
            resolve: func
            );
    }
        public async Task <IHttpActionResult> GetDriod(string id)
        {
            var data = new StarWarsData();

            var item = await data.GetDroidByIdAsync(id);

            return(Ok(item));
        }
        public HttpResponseMessage GetHero()
        {
            var data = new StarWarsData();

            var item = data.GetDroidByIdAsync("3").Result;

            return(Request.CreateResponse(HttpStatusCode.OK, item));
        }
Beispiel #5
0
 public void AddGraphTypeFields(QueryCore queryCore)
 {
     var fieldType = queryCore.FieldAsync <CharacterInterface>(
         name: "hero",
         description: null,
         resolve: async context =>
     {
         var result = await _starWarsData.GetDroidByIdAsync("3");
         return(result);
     });
 }
Beispiel #6
0
        public void AddGraphTypeFields(QueryCore queryCore)
        {
            Func <ResolveFieldContext, string, object> func = (context, id) => _starWarsData.GetDroidByIdAsync(id);

            queryCore.FieldDelegate <DroidType>(
                "droid",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id", Description = "id of the droid"
            }
                    ),
                resolve: func
                );
        }
        public StarWarsQuery(StarWarsData data)
        {
            Name        = "StarWarsContext";
            Description = "StarWars Context";

            Func <ResolveFieldContext, string, object> func = (context, id) => data.GetDroidByIdAsync(id);

            FieldDelegate <DroidType>(
                "droid",
                "Get droid by Id",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "id", Description = "id of the droid"
            }
                    ),
                resolve: func
                );
        }
        public Droid Hero()
        {
            var item = _data.GetDroidByIdAsync("3").Result;

            return(item);
        }