OrderBy Inputs
OrderByInput types for sorting GraphQL query results
Audience: Programmer
OrderByInput types define how query results should be sorted in the pyck GraphQL API. They provide a standardized way to order results by various fields in ascending or descending order.
Common Structure
All OrderByInput types follow a consistent pattern:
input EntityOrder {
field: EntityOrderField!
direction: OrderDirection! = ASC
}Where:
field: An enum specifying which field to sort bydirection: EitherASC(ascending) orDESC(descending)
Usage Examples
Basic Sorting
Sort inventory items by name in ascending order:
query {
inventoryItems(orderBy: { field: NAME, direction: ASC }) {
edges {
node {
id
name
sku
}
}
}
}Descending Order
Sort picking orders by creation date (newest first):
JavaScript Example
Available Order Types
The following Order input types are available in pyck:
CustomerOrder
Customers
TENANT_ID, CREATED_AT, CREATED_BY
DataTypeOrder
Data type definitions
NAME, SLUG, CREATED_AT
EventOrder
Event definitions
NAME, TOPIC, CREATED_AT
FileOrder
File attachments
NAME, SIZE, CREATED_AT
GroupOrder
User groups
NAME, CREATED_AT
InventoryCollectionOrder
Inventory collections
HANDLER, CREATED_AT
InventoryItemOrder
Inventory items
SKU, CREATED_AT
InventoryItemSetOrder
Item sets
SKU, CREATED_AT
ItemMovementOrder
Item movements
CREATED_AT, EXECUTED_AT
KeyValueOrder
Key-value pairs
NAME, CREATED_AT
PickingOrderOrder
Picking orders
CUSTOMER_ID, CREATED_AT
PickingOrderItemOrder
Picking order items
SKU, QUANTITY, CREATED_AT
ReceivingInboundOrder
Receiving inbounds
ORDER_ID, SUPPLIER_ID, CREATED_AT
ReceivingInboundItemOrder
Inbound items
SKU, QUANTITY, CREATED_AT
RepositoryOrder
Repositories
NAME, TYPE, CREATED_AT
RepositoryMovementOrder
Repository movements
CREATED_AT, EXECUTED_AT
RoleOrder
User roles
NAME, CREATED_AT
StockOrder
Stock levels
CREATED_AT, QUANTITY
SupplierOrder
Suppliers
TENANT_ID, CREATED_AT
TenantOrder
Tenants
NAME, CREATED_AT
TransactionOrder
Transactions
TYPE, CREATED_AT
UserOrder
Users
USERNAME, EMAIL, CREATED_AT
WorkflowOrder
Workflows
NAME, ACTIVE, CREATED_AT
WorkflowSignalOrder
Workflow signals
EVENT_NAME, CREATED_AT
Order Field Enums
Each entity has its own OrderField enum defining sortable fields. Common fields include:
NAME- Entity nameCREATED_AT- Creation timestampUPDATED_AT- Last update timestampREFERENCE_ID- External reference identifierSKU- Stock keeping unitEMAIL- Email addressTYPE- Entity typeEXECUTED_AT- Execution timestamp
Best Practices
Default Sorting: Consider providing a default sort order when none is specified
Performance: Be aware that sorting by non-indexed fields may impact query performance
Consistency: Use consistent sorting across related queries for better UX
Null Values: Understand how null values are sorted (typically first for ASC, last for DESC)
Combining with Pagination
OrderByInput works seamlessly with cursor-based pagination:
See Also
WhereInput Types for filtering
Pagination for cursor-based pagination
OrderDirection Enum for sort directions
Last updated
Was this helpful?
