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")) ); }
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 void AddGraphTypeFields(QueryCore queryCore) { var fieldType = queryCore.FieldAsync <HumanType>( name: "human", description: null, arguments: new QueryArguments(new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "id", Description = "id of the human" }), resolve: async context => { try { var userContext = context.UserContext.As <GraphQLUserContext>(); var human = await _starWarsData.GetHumanByIdAsync(context.GetArgument <string>("id")); return(human); } catch (Exception e) { } return(null); // return await Task.Run(() => { return ""; }); }, deprecationReason: null); }
public async Task <IHttpActionResult> GetHuman(string id) { var data = new StarWarsData(); var item = await data.GetHumanByIdAsync(id); return(Ok(item)); }
private IObservable <Human> Subscribe(ResolveEventStreamContext context) { List <Human> listOfHumans = new List <Human>(); var task = _starWarsData.GetHumanByIdAsync("1"); task.Wait(); var result = task.Result; if (result != null) { listOfHumans.Add(task.Result); } task = _starWarsData.GetHumanByIdAsync("2"); task.Wait(); result = task.Result; if (result != null) { listOfHumans.Add(task.Result); } return(listOfHumans.ToObservable()); }
public Task <Human> GetHumanByIdAsync(string id) { var item = _data.GetHumanByIdAsync(id); return(item); }