我正在执行一个 GraphQL 查询:
export const userByName = /* GraphQL */ `
query employee(
$first_name: String
$sortDirection: ModelSortDirection
$filter: ModelUserFilterInput
$limit: Int
$nextToken: String
) {
employee(
first_name: $first_name
sortDirection: $sortDirection
filter: $filter
limit: $limit
nextToken: $nextToken
) {
items {
id
employee_type
first_name
last_name
createdAt
updatedAt
}
nextToken
}
}
`;
当我执行这个查询时,我得到这个错误:
sortDirection is not supported for List operations without a Sort key defined.
我正在使用以下代码执行此查询:
const userInfo = await API.graphql(
graphqlOperation(employee, {
first_name: name,
sortDirection: 'DESC'
})
)
我正在尝试检索数据,但出现上述错误。我也尝试过删除sortDirection
,但我只是得到一个空数组作为响应。