Unification of count fields
API
Effective April 01, 2024
Action required
As of 2024-04
, fields that returned a count of resources will be removed and replaced with new count fields that have consistent API design and improved features.
API design and naming
Count fields are now standalone fields with a common naming pattern and their own arguments instead of being a field under a connection type.
Before:
query {
products(first: 0) {
totalCount
}
}
After:
query {
productsCount {
count
}
}
In the before example, the products
connection field was overloaded with multiple behaviors (count and pagination) which caused confusion as to how, and if, arguments affected the resulting count.
With the new count fields, there's one clear behavior and it simplifies how field arguments affect the count.
Return type
Instead of varying Int
or UnsignedInt64
return type, all count fields now return a Count
object type with precision
and count
fields.
Precision
The new precision
field indicates if a server limit was reached such that we returned early, reporting that there were "at least" n records.
For example, counting the number of products has a server limit of 10,000
. If there were 42
products, the count object would look like { count: 42, precision: "EXACT" }
. If there were 10,042
products, the count object would look like { count: 10000, precision: "AT_LEAST" }
Filtering
Some count fields will now accept filter arguments matching that of a neighboring connection, such as products
and productsCount
.
Migration
CatalogConnection.totalCount
-->CompanyLocation.catalogsCount
,Market.catalogsCount
,QueryRoot.catalogsCount
Collection.availablePublicationCount
-->Collection.availablePublicationsCount
Collection.productsCount
-->Collection.productsCount
Collection.publicationCount
-->Collection.resourcePublicationsCount
Company.contactCount
-->Company.contactsCount
Company.locationCount
-->Company.locationsCount
Company.orderCount
-->Company.ordersCount
CompanyLocation.orderCount
-->CompanyLocation.ordersCount
CompanyLocationCatalog.companyLocationsCount
-->CompanyLocationCatalog.companyLocationsCount
CustomerJourneySummary.momentsCount
-->CustomerJourneySummary.momentsCount
DeliveryLocationGroup.locationsCount
-->DeliveryLocationGroup.locationsCount
DeliveryProfile.productVariantsCount
-->DeliveryProfile.productVariantsCount
DeliveryProfile.productVariantsCountV2
-->DeliveryProfile.productVariantsCount
DiscountCodeApp.codeCount
-->DiscountCodeApp.codesCount
DiscountCodeBasic.codeCount
-->DiscountCodeBasic.codesCount
DiscountCodeBxgy.codeCount
-->DiscountCodeBxgy.codesCount
DiscountCodeFreeShipping.codeCount
-->DiscountCodeFreeShipping.codesCount
FulfillmentOrderLocationForMove.availableLineItemsCount
-->FulfillmentOrderLocationForMove.availableLineItemsCount
FulfillmentOrderLocationForMove.unavailableLineItemsCount
-->FulfillmentOrderLocationForMove.unavailableLineItemsCount
InventoryItem.locationsCount
-->InventoryItem.locationsCount
PriceRule.discountCodesCount
-->PriceRule.discountCodesCount
Product.availablePublicationCount
-->Product.availablePublicationsCount
Product.mediaCount
-->Product.mediaCount
Product.publicationCount
-->Product.resourcePublicationsCount
Product.sellingPlanGroupCount
-->Product.sellingPlanGroupsCount
Product.totalVariants
-->Product.variantsCount
ProductBundleComponent.componentVariantsCount
-->ProductBundleComponent.componentVariantsCount
ProductBundleComponent.nonComponentVariantsCount
-->ProductBundleComponent.nonComponentVariantsCount
ProductComponentType.componentVariantsCount
-->ProductComponentType.componentVariantsCount
ProductComponentType.nonComponentVariantsCount
-->ProductComponentType.nonComponentVariantsCount
ProductConnection.totalCount
-->Channel.productsCount
,Collection.productsCount
,QueryRoot.productsCount
ProductVariant.sellingPlanGroupCount
-->ProductVariant.sellingPlanGroupsCount
Publishable.availablePublicationCount
-->Publishable.availablePublicationsCount
Publishable.publicationCount
-->Publishable.resourcePublicationsCount
QueryRoot.channelCount
-->QueryRoot.publicationsCount
QueryRoot.companyCount
-->QueryRoot.companiesCount
QueryRoot.discountCodeCount
-->QueryRoot.discountCodesCount
QueryRoot.giftCardsCount
-->QueryRoot.giftCardsCount
QueryRoot.publicationCount
-->QueryRoot.publicationsCount
QueryRoot.segmentCount
-->QueryRoot.segmentsCount
SellingPlanGroup.productCount
-->SellingPlanGroup.productsCount
SellingPlanGroup.productVariantCount
-->SellingPlanGroup.productVariantsCount
Shop.limitedPendingOrderCount
-->QueryRoot.pendingOrdersCount
Shop.pendingOrdersCount
-->QueryRoot.pendingOrdersCount
SubscriptionBillingCycleEditedContract.lineCount
-->SubscriptionBillingCycleEditedContract.linesCount
SubscriptionContract.lineCount
-->SubscriptionContract.linesCount
SubscriptionContractBase.lineCount
-->SubscriptionContractBase.linesCount