gitlabhq/gitlabhq · error · GraphQL::ExecutionError
orderBy parameter must contain one key-value pair.
Error message
orderBy parameter must contain one key-value pair.
What it means
Types::DeploymentsOrderByInputType#prepare (app/graphql/types/deployments_order_by_input_type.rb:19) raises GraphQL::ExecutionError unless the input object hashes to exactly one key. The type exposes createdAt and finished_at sort directions, and the deployments query plan supports ordering by only one of them at a time. Passing both or neither aborts the query with 'orderBy parameter must contain one key-value pair.'.
Source
Thrown at app/graphql/types/deployments_order_by_input_type.rb:19
# frozen_string_literal: true
module Types
class DeploymentsOrderByInputType < BaseInputObject
graphql_name 'DeploymentsOrderByInput'
description 'Values for ordering deployments by a specific field'
argument :created_at,
Types::SortDirectionEnum,
required: false,
description: 'Order by Created time.'
argument :finished_at,
Types::SortDirectionEnum,
required: false,
description: 'Order by Finished time.'
def prepare
raise GraphQL::ExecutionError, 'orderBy parameter must contain one key-value pair.' unless to_h.size == 1
super
end
end
end
View on GitHub (pinned to 55ee20384a)
Solutions
- Pass exactly one key: orderBy: {createdAt: DESC} or orderBy: {finishedAt: ASC}.
- In code, pick the first active sort criterion and send only it: const orderBy = { [firstSort.field]: firstSort.dir }.
- When no sorting is requested, omit the orderBy argument instead of sending {}.
- If combined sorting is a real requirement, propose a schema change on the GitLab side; the current type intentionally forbids it.
Example fix
# before
query($orderBy: DeploymentsOrderByInput) { deployments(orderBy: $orderBy) { ... } }
# variables: {"orderBy": {"createdAt": "DESC", "finishedAt": "ASC"}}
# after
# variables: {"orderBy": {"createdAt": "DESC"}} Defensive patterns
Strategy: validation
Validate before calling
// JS: build orderBy from a single active sort
const orderBy = sorts.length === 1 ? { [sorts[0].field]: sorts[0].dir } : undefined;
const variables = { ...(orderBy && { orderBy }) }; Type guard
function isValidOrderBy(o) {
return o == null || (Object.keys(o).length === 1 && ['createdAt', 'finishedAt'].includes(Object.keys(o)[0]));
} Prevention
- Model the sort as a single (field, direction) pair in client state, not a dict.
- Add a client-side assertion Object.keys(orderBy).length === 1 before fetching.
- Remember other GitLab orderBy types have different rules — do not generalize.
When it happens
Trigger: Querying project/group deployments with orderBy: {} (no keys) or orderBy: {createdAt: DESC, finishedAt: ASC} (two keys). Programmatic clients that build the orderBy dict from a list of sort criteria easily emit multi-key objects.
Common situations: Frontend tables that map several column sorts into one GraphQL call; copying examples from issue/MR queries whose orderBy types accept multiple keys; defaulting orderBy to an empty object when the user has no sort selected.
Related errors
- `updated_at` filter requires `updated_at` sort
- `finished_at` filter requires `finished_at` sort.
- `finished_at` sort requires `finished_at` filter or a filter
- At least one property of `#{self.class.graphql_name}` must b
- Request denied. Spam detected
AI-assisted analysis of gitlabhq/gitlabhq@55ee20384a (2026-08-21).
Data as JSON: /api/errors/d74c5e7bcb8bd8e3.
Report an issue: GitHub.