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); FieldDelegate <DroidType>( "droid", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "id", Description = "id of the droid" } ), resolve: func ); }
public StarWarsMutation(StarWarsData data) { Name = "Mutation"; Field <HumanType>( "createHuman", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <HumanInputType> > { Name = "human" } ), resolve: context => { var human = context.GetArgument <Human>("human"); return(data.AddCharacter(human)); }); }