Query Complexity
Query complexity measures the cost of executing a GraphQL query and is affected by the graph, selected fields, page size, filters, and nesting. Reducing complexity improves DaaS API performance and user experience.
Tips to minimize complexity include:
- Minimize nesting and include only necessary fields.
- Avoid nested list-type subgraphs in bulk pulls; instead use multiple queries joined by foreign keys.
- Use filters to reduce response size.
- If needed, reduce page size for complex queries
The following query illustrates a complex nested query that includes list type subgraphs with a large page size and no filters.
# maximum page size # no additional filters # complex graph type including all fields # nested sub-graphs including invoice and disbursable sub-graphs that return lists of nested objects |
|---|
An optimized approach splits the data pull into several flatter queries, which can be joined externally using foreign key relationships in a data mart.
# a flat contract query to pull required fields and a foreign key relation to a project query Contract { contract(offset: 0, next: 1000, organizationID: <id>, isDeleted: false) { id dateModified comment contractDate dateConfirmed dateCreated description isComplete contractNumber selfBalanceDue selfBilledToDate selfChangeOrderAmount selfContractAmount selfOriginalContractAmount selfPercentCompleteToDate selfRetentionToDate selfPriorOffSystemPayment subcontractedBalanceDue subcontractedBilledToDate subcontractedChangeOrderAmount subcontractedContractAmount subcontractedOriginalContractAmount subcontractedPercentCompleteToDate subcontractedRetentionToDate subcontractedPriorOffSystemPayment vendorID tpaStatus tpaSubFeePercentage isDeleted project { id } pageInfo { pageResults totalResults } } }
# a flat disbursable query to pull required fields and a foreign key relation to a contract query Disbursable { disbursable(offset: 0, next: 1000, organizationID: <id>) { id segmentID dateAuthorized disbursedPreviously discountAmount discountTaxAmount fundingBankAccount fundingCutOffDate invoiceSubmitted netInvoiceAmount ownerFundingAmount ownerFundingComment ownerFundingDate paidAmount paymentAmount paymentAmountRemaining paymentDueDate paymentMethod paymentTaxAmount taxAmount contract { id } pageInfo { pageResults totalResults } } }
# a flat invoice query to pull required fields and a foreign key relation to a contract query Invoice { invoice(offset: 0, next: 1000, organizationID: <id>, isDeleted: false) { id invoiceNumber systemGeneratedInvoiceNumber selfWorkThisPeriod subcontractedWorkThisPeriod selfMaterialStoredThisPeriod subcontractedMaterialStoredThisPeriod selfBilledAmountThisPeriod subcontractedBilledAmountThisPeriod selfRetentionAmountThisPeriod subcontractedRetentionAmountThisPeriod selfRetentionReleasedThisPeriod subcontractedRetentionReleasedThisPeriod taxAmount submitDate approvedDate authorizedDate invoiceStatus netPaymentDue netInvoiceAmount paymentDueDate hoursWorked discount discountExpirationDate isDeleted exportDate rejectionExportDate exportJobID rejectionExportJobID dateModified contract { id } pageInfo { pageResults totalResults } } }
# a flat project query |
|---|
Last Published Friday, January 16, 2026