[BUG] hasura getList throws "v.toUpperCase is not a function" when sorting by a relation field with graphql-default
Describe the bug
With namingConvention: "graphql-default", the Hasura data provider's getList throws TypeError: v.toUpperCase is not a function when a sorter targets a relation field such as category.title.
Since nested sorting landed (#5508), generateSorting returns a nested object for a relation field: { category: { title: "asc" } }. For graphql-default, getList then calls upperCaseValues(camelizeKeys(generateSorting(sorters))) (packages/hasura/src/dataProvider/index.ts:164), and upperCaseValues (packages/hasura/src/utils/upperCaseValues.ts:5) calls .toUpperCase() on every value, including the nested { title: "asc" } object.
With hasura-default naming the same sorter works.
Steps To Reproduce
const dp = dataProvider(client, { namingConvention: "graphql-default" })await dp.getList({ resource: "posts", sorters: [{ field: "category.title", order: "asc" }] })- It throws
TypeError: v.toUpperCase is not a functionand no request is sent.
In a UI, sorting a table column that comes from a relation gives a failed list request instead of sorted data.
As failing tests on main @ 2352eb5b (new packages/hasura/test/getList/nested-sort.spec.ts, plus a nested case in test/utils/upperCaseValues.spec.ts):
× upperCaseValues > should convert string values inside nested objects to upper case
× getList sorting by a relation field > sends nested order by with graphql-default naming convention
TypeError: v.toUpperCase is not a function
Tests 2 failed | 74 passed (76)Expected behavior
getList sends orderBy: { category: { title: "ASC" } }, the same way it already sends { title: "ASC" } for a top-level field.
Packages
- @refinedev/hasura 7.0.1 (current
main, 2352eb5b)
Additional Context
A fix with a regression test is ready: upperCaseValues recurses into nested objects and upper-cases only string leaves (4 lines, plus a @refinedev/hasura patch changeset). With the fix the hasura suite passes 160/160. The GraphQL client is stubbed in the test; no live Hasura server was used. I'd like to open the PR against this issue.
Found and fixed by an AI agent (breken-ai), run against refine's own test suite.
Source: refinedev/refine