private async Task <object> ResolvePaymentsConnectionAsync(IMediator mediator, IResolveConnectionContext <object> context) { var query = context.ExtractQuery <SearchPaymentsQuery>(); var authorizationResult = await _authorizationService.AuthorizeAsync(context.GetCurrentPrincipal(), query, new CanAccessOrderAuthorizationRequirement()); if (!authorizationResult.Succeeded) { throw new AuthorizationError($"Access denied"); } context.UserContext.Add(nameof(Currency.CultureName).ToCamelCase(), query.CultureName); var response = await mediator.Send(query); foreach (var payment in response.Results) { context.SetExpandedObjectGraph(payment); } var allCurrencies = await _currencyService.GetAllCurrenciesAsync(); //Store all currencies in the user context for future resolve in the schema types context.SetCurrencies(allCurrencies, query.CultureName); return(new PagedConnection <PaymentIn>(response.Results, query.Skip, query.Take, response.TotalCount)); }