Check JSONAPI sorting (#1234)

<!-- The PR description should answer 2 important questions: -->

### What

Wasn't sure what was implemented, added some tests, it's working.

This PR is stacked on top of
https://github.com/hasura/v3-engine/pull/1233

V3_GIT_ORIGIN_REV_ID: fbfce6dd8ce325c5a1659db2755a09c7728030f2
This commit is contained in:
Daniel Harvey 2024-10-18 11:46:27 +01:00 committed by hasura-bot
parent db19cf965a
commit 065035631c
6 changed files with 146 additions and 0 deletions

View File

@ -0,0 +1 @@
fields[Artist]=ArtistId,Name&page[offset]=0&page[limit]=5&sort=Name

View File

@ -0,0 +1 @@
fields[Artist]=ArtistId,Name&page[offset]=0&page[limit]=5&sort=-Name

View File

@ -0,0 +1,72 @@
---
source: crates/jsonapi/tests/jsonapi_golden_tests.rs
expression: result
input_file: crates/jsonapi/tests/passing/ordering/Artist.txt
---
DocumentData {
data: Some(
Multiple(
[
Resource {
_type: "default_Artist",
id: "1",
attributes: {
"ArtistId": Number(230),
"Name": String("Aaron Copland & London Symphony Orchestra"),
},
relationships: None,
links: None,
meta: None,
},
Resource {
_type: "default_Artist",
id: "2",
attributes: {
"ArtistId": Number(202),
"Name": String("Aaron Goldberg"),
},
relationships: None,
links: None,
meta: None,
},
Resource {
_type: "default_Artist",
id: "3",
attributes: {
"ArtistId": Number(215),
"Name": String("Academy of St. Martin in the Fields Chamber Ensemble & Sir Neville Marriner"),
},
relationships: None,
links: None,
meta: None,
},
Resource {
_type: "default_Artist",
id: "4",
attributes: {
"ArtistId": Number(222),
"Name": String("Academy of St. Martin in the Fields, John Birch, Sir Neville Marriner & Sylvia McNair"),
},
relationships: None,
links: None,
meta: None,
},
Resource {
_type: "default_Artist",
id: "5",
attributes: {
"ArtistId": Number(214),
"Name": String("Academy of St. Martin in the Fields & Sir Neville Marriner"),
},
relationships: None,
links: None,
meta: None,
},
],
),
),
included: None,
links: None,
meta: None,
jsonapi: None,
}

View File

@ -0,0 +1,72 @@
---
source: crates/jsonapi/tests/jsonapi_golden_tests.rs
expression: result
input_file: crates/jsonapi/tests/passing/reversed-ordering/Artist.txt
---
DocumentData {
data: Some(
Multiple(
[
Resource {
_type: "default_Artist",
id: "1",
attributes: {
"ArtistId": Number(155),
"Name": String("Zeca Pagodinho"),
},
relationships: None,
links: None,
meta: None,
},
Resource {
_type: "default_Artist",
id: "2",
attributes: {
"ArtistId": Number(212),
"Name": String("Yo-Yo Ma"),
},
relationships: None,
links: None,
meta: None,
},
Resource {
_type: "default_Artist",
id: "3",
attributes: {
"ArtistId": Number(168),
"Name": String("Youssou E'Dour"),
},
relationships: None,
links: None,
meta: None,
},
Resource {
_type: "default_Artist",
id: "4",
attributes: {
"ArtistId": Number(255),
"Name": String("Yehudi Menuhin"),
},
relationships: None,
links: None,
meta: None,
},
Resource {
_type: "default_Artist",
id: "5",
attributes: {
"ArtistId": Number(181),
"Name": String("Xis"),
},
relationships: None,
links: None,
meta: None,
},
],
),
),
included: None,
links: None,
meta: None,
jsonapi: None,
}