Hi,
The Resolve function of graphQL query takes long to hit. For example if I run below query from GraphQL playground, it taks almost 4 seconds to hit the breakpoint put on the first line of Resolve function in UserQuery.cs file. First execution of query, I can understand it might be taking some time as the GrpahQL engine might be instantiating. But for subsequent query as well it takes considerable amount of time (almost 4 seconds) to hit the first line of the Resolve function of UserQuery.cs file.
`query getAll { users{ items{ id name surname }
} }`
Any indea to boost this performance would be of great help.
Regards, Mahendra
4 Answer(s)
-
0
Hi,
Just to let you know, below is my QueryContainer class. I have many GraphQL queries inside it. If I comment all and leave one (the one I'll query) say if I leave "ProductQuery productQuery" uncommented and comment the rest, then it works fast. But if I have all the below queries uncommented then, it becomes slow.
Any hint would be appreciated.. Regards, Mahendra
using Abp.Dependency; using GraphQL.Types;
namespace CitiXsys.iVend.Queries.Container { public sealed class QueryContainer : ObjectGraphType, ITransientDependency { public QueryContainer(RoleQuery roleQuery, UserQuery userQuery, OrganizationUnitQuery organizationUnitQuery, AuditLogQuery auditLogQuery, ProductQuery productQuery, TeamQuery teamQuery, VendorGroupQuery vendorGroupQuery, RetailProfileQuery retailProfileQuery, FulfillmentQuery fulfillmentQuery, SurchargeQuery surchargeQuery, WarehouseQuery warehouseQuery, ManufacturerQuery manufacturerQuery, CountryQuery countryQuery, BankQuery bankQuery, DepartmentQuery departmentQuery, JobCodeQuery jobCodeQuery, ReasonCodeQuery reasonCodeQuery, BarCodeMaskQuery barCodeMaskQuery, ShippingTypeQuery shippingTypeQuery, ProductGroupQuery productGroupQuery, RetailEventQuery retailEventQuery, RetailMessageQuery retailMessageQuery, POSQuery cashRegisterQuery, CurrencyQuery currencyQuery, CustomerQuery customerQuery, CustomerGroupQuery customerGroupQuery, ExpenseQuery expenseQuery, TaxEventQuery taxEventQuery, ValidationRuleQuery validationRuleQuery, PriceConditionQuery priceConditionQuery, VendorQuery vendorQuery, TaxGroupQuery productClassQuery, PurchaseOrderQuery purchaseOrderQuery, GoodsReceiptQuery goodsReceiptQuery, GoodsIssueQuery goodsIssueQuery, SaleAttributeQuery saleAttributeQuery, StockTransferQuery stockTransferQuery, StateQuery stateQuery, LineAttributeQuery lineAttributeQuery, LoyaltySetupQuery loyaltySetupQuery, LayawayPlanQuery layawayPlanQuery, InventoryCycleSetupQuery inventoryCycleSetupQuery, StockTransferRequestQuery stockTransferRequestQuery, SecurityUserQuery securityUserQuery, ProductCategoryQuery productCategoryQuery, LoyaltyLevelQuery loyaltyLevelQuery, PaymentTypeQuery paymentTypeQuery, TaxJurisdictionQuery taxJurisdictionQuery, TaxAreaQuery taxAreaQuery, TaxConditionQuery taxConditionQuery, TillMasterQuery tillMasterQuery, TillQuery tillQuery, RegisteredApplicationQuery registeredApplicationQuery, GiftCertificateQuery giftCertificateQuery, GiftCertificateManagementQuery giftCertificateManagementQuery, MerchandiseHierarchyDetailQuery merchandiseHierarchyDetailQuery, CouponQuery couponQuery, RetailTransactionQuery retailTransactionQuery, SalesTargetQuery salesTargetQuery, PrintFormatQuery printFormatQuery, InventoryReportQuery inventoryReportQuery, SecurityRoleQuery securityRoleQuery,
TenderCollectionReportQuery tenderCollectionReportQuery, InventoryMovementReportQuery inventoryMovementReportQuery, TaxCollectionReportQuery taxCollectionReportQuery, TaxPayableReportQuery taxPayableReportQuery, SalesTargetReportQuery salesTargetReportQuery, TaxCodeQuery taxCodeQuery, SalesReportQuery salesReportQuery, CustomerReportQuery customerReportQuery) { AddField(roleQuery.GetFieldType()); AddField(organizationUnitQuery.GetFieldType()); AddField(userQuery.GetFieldType()); AddField(auditLogQuery.GetFieldType()); AddField(productQuery.GetFieldType()); AddField(teamQuery.GetFieldType()); AddField(vendorGroupQuery.GetFieldType()); AddField(retailProfileQuery.GetFieldType()); AddField(fulfillmentQuery.GetFieldType()); AddField(surchargeQuery.GetFieldType()); AddField(warehouseQuery.GetFieldType()); AddField(manufacturerQuery.GetFieldType()); AddField(countryQuery.GetFieldType()); AddField(bankQuery.GetFieldType()); AddField(departmentQuery.GetFieldType()); AddField(jobCodeQuery.GetFieldType()); AddField(reasonCodeQuery.GetFieldType()); AddField(barCodeMaskQuery.GetFieldType()); AddField(shippingTypeQuery.GetFieldType()); AddField(productGroupQuery.GetFieldType()); AddField(retailEventQuery.GetFieldType()); AddField(retailMessageQuery.GetFieldType()); AddField(cashRegisterQuery.GetFieldType()); AddField(currencyQuery.GetFieldType()); AddField(customerQuery.GetFieldType()); AddField(customerGroupQuery.GetFieldType()); AddField(expenseQuery.GetFieldType()); AddField(taxEventQuery.GetFieldType()); AddField(validationRuleQuery.GetFieldType()); AddField(priceConditionQuery.GetFieldType()); AddField(productClassQuery.GetFieldType()); AddField(vendorQuery.GetFieldType()); AddField(purchaseOrderQuery.GetFieldType()); AddField(saleAttributeQuery.GetFieldType()); AddField(lineAttributeQuery.GetFieldType()); AddField(inventoryCycleSetupQuery.GetFieldType()); AddField(goodsReceiptQuery.GetFieldType()); AddField(stockTransferQuery.GetFieldType()); AddField(stateQuery.GetFieldType()); AddField(goodsIssueQuery.GetFieldType()); AddField(loyaltySetupQuery.GetFieldType()); AddField(layawayPlanQuery.GetFieldType()); AddField(stockTransferRequestQuery.GetFieldType()); AddField(securityUserQuery.GetFieldType()); AddField(productCategoryQuery.GetFieldType()); AddField(loyaltyLevelQuery.GetFieldType()); AddField(paymentTypeQuery.GetFieldType()); AddField(taxJurisdictionQuery.GetFieldType()); AddField(taxAreaQuery.GetFieldType()); AddField(taxConditionQuery.GetFieldType()); AddField(tillMasterQuery.GetFieldType()); AddField(tillQuery.GetFieldType()); AddField(registeredApplicationQuery.GetFieldType()); AddField(giftCertificateQuery.GetFieldType()); AddField(giftCertificateManagementQuery.GetFieldType()); AddField(merchandiseHierarchyDetailQuery.GetFieldType()); AddField(couponQuery.GetFieldType()); AddField(retailTransactionQuery.GetFieldType()); AddField(salesTargetQuery.GetFieldType()); AddField(printFormatQuery.GetFieldType()); AddField(inventoryReportQuery.GetFieldType()); AddField(securityRoleQuery.GetFieldType()); AddField(tenderCollectionReportQuery.GetFieldType()); AddField(inventoryMovementReportQuery.GetFieldType()); AddField(taxCollectionReportQuery.GetFieldType()); AddField(taxPayableReportQuery.GetFieldType()); AddField(salesTargetReportQuery.GetFieldType()); AddField(taxCodeQuery.GetFieldType()); AddField(salesReportQuery.GetFieldType()); AddField(customerReportQuery.GetFieldType()); } }
}
-
0
Hi Expert,
I have added the singleton dependency see the bold line below and I get the optimum performance now. Is the following changes ok? Please confirm.
if (WebConsts.GraphQL.Enabled) { services.AddAndConfigureGraphQL(); services.AddSingleton<QueryContainer>(); }
-
0
This will improve the performance, but becareful with the public static values in your Query classes. If you hold a public static value in your Query class, and if that changes in different scenarios, you may have issues. Otherwise, you are good to change this to
ISingletonDependency
. -
0
Thanks....much appreciated....