Support orderBy as array (#5681)
closes: #4301 --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
@ -24,7 +24,7 @@ export const query = gql`
|
||||
export const findManyViewsQuery = gql`
|
||||
query FindManyViews(
|
||||
$filter: ViewFilterInput
|
||||
$orderBy: ViewOrderByInput
|
||||
$orderBy: [ViewOrderByInput]
|
||||
$lastCursor: String
|
||||
$limit: Int
|
||||
) {
|
||||
|
||||
@ -26,8 +26,8 @@ describe('useGetObjectOrderByField', () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.current).toEqual({
|
||||
name: { firstName: 'AscNullsLast', lastName: 'AscNullsLast' },
|
||||
});
|
||||
expect(result.current).toEqual([
|
||||
{ name: { firstName: 'AscNullsLast', lastName: 'AscNullsLast' } },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@ -9,8 +9,8 @@ describe('getObjectOrderByField', () => {
|
||||
(item) => item.nameSingular === 'person',
|
||||
)!;
|
||||
const res = getOrderByFieldForObjectMetadataItem(objectMetadataItem);
|
||||
expect(res).toEqual({
|
||||
name: { firstName: 'AscNullsLast', lastName: 'AscNullsLast' },
|
||||
});
|
||||
expect(res).toEqual([
|
||||
{ name: { firstName: 'AscNullsLast', lastName: 'AscNullsLast' } },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@ -15,20 +15,26 @@ export const getOrderByFieldForObjectMetadataItem = (
|
||||
if (isDefined(labelIdentifierFieldMetadata)) {
|
||||
switch (labelIdentifierFieldMetadata.type) {
|
||||
case FieldMetadataType.FullName:
|
||||
return {
|
||||
[labelIdentifierFieldMetadata.name]: {
|
||||
firstName: orderBy ?? 'AscNullsLast',
|
||||
lastName: orderBy ?? 'AscNullsLast',
|
||||
return [
|
||||
{
|
||||
[labelIdentifierFieldMetadata.name]: {
|
||||
firstName: orderBy ?? 'AscNullsLast',
|
||||
lastName: orderBy ?? 'AscNullsLast',
|
||||
},
|
||||
},
|
||||
};
|
||||
];
|
||||
default:
|
||||
return {
|
||||
[labelIdentifierFieldMetadata.name]: orderBy ?? 'AscNullsLast',
|
||||
};
|
||||
return [
|
||||
{
|
||||
[labelIdentifierFieldMetadata.name]: orderBy ?? 'AscNullsLast',
|
||||
},
|
||||
];
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
createdAt: orderBy ?? 'DescNullsLast',
|
||||
};
|
||||
return [
|
||||
{
|
||||
createdAt: orderBy ?? 'DescNullsLast',
|
||||
},
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user