public Query( ApplicationByIdLoader applicationLoader, IHttpContextAccessor httpContextAccessor, IListApplicationService listApplicationService, IVerifySecretService verifySecretService) { Field <ApplicationType, Application>() .Name("application") .ResolveAsync(x => verifySecretService.Verify(httpContextAccessor.GetAppCredentials())); Field <ApplicationType, Application>() .Name("applicationById").Argument <NonNullGraphType <StringGraphType> >("id") .ResolveAsync(async x => { var application = await applicationLoader.LoadAsync(x.GetArgument <string>("id")).GetResultAsync(); return(await listApplicationService.VerifyOwnership(application, httpContextAccessor.GetUserId())); }) .Authorize(); }
public ApplicationType(ApplicationByIdLoader applicationLoader) { Name = "Application"; Key("id"); Field("id", x => x.Id).Description("application id"); Field("name", x => x.Name).Description("name of application given by user"); Field("secret", x => x.Secret, true).Description("app_secret (only visible during creation of app)"); Field("created_at", x => x.CreatedAt).Description("application creation time"); Field <global::GraphQL.Types.NonNullGraphType <UserType>, User>().Name("owner") .Resolve(x => new User { Id = x.Source.User }); ResolveReferenceAsync(async x => { var id = x.Arguments["id"].ToString(); return(await applicationLoader.LoadAsync(id).GetResultAsync()); }); }