Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/offset-pagination #174

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/discord-pr-notifications.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Pull Request Notification to Discord

on:
pull_request:
types: [opened, closed]

jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Send notification to Discord
env:
WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
curl -X POST -H "Content-Type: application/json" \
-d "{\"content\": \"🔔 New Pull Request: **${{ github.event.pull_request.title }}** by ${{ github.actor }} - ${{ github.event.pull_request.html_url }}\"}" \
$WEBHOOK_URL
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ categories = ["database"]

[dependencies]
async-graphql = { version = "7.0", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] }
sea-orm = { version = "~1.1.0-rc.1", default-features = false, features = ["seaography"] }
sea-orm = { version = "1.0.*", default-features = false, features = ["seaography"] }
itertools = { version = "0.12.0" }
heck = { version = "0.4.1" }
thiserror = { version = "1.0.44" }
Expand All @@ -32,5 +32,6 @@ with-uuid = ["sea-orm/with-uuid"]
with-decimal = ["sea-orm/with-rust_decimal", "async-graphql/decimal"]
with-bigdecimal = ["sea-orm/with-bigdecimal", "async-graphql/bigdecimal"]
with-postgres-array = ["sea-orm/postgres-array"]
offset-pagination = []
# with-ipnetwork = ["sea-orm/with-ipnetwork"]
# with-mac_address = ["sea-orm/with-mac_address"]
# with-mac_address = ["sea-orm/with-mac_address"]
5 changes: 4 additions & 1 deletion examples/mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ features = ["with-decimal", "with-chrono"]
[dev-dependencies]
serde_json = { version = "1.0.103" }

[features]
offset-pagination = ["seaography/offset-pagination"]

[workspace]
members = []
members = []
3 changes: 2 additions & 1 deletion examples/mysql/tests/mutation_tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use async_graphql::{dynamic::*, Response};
use sea_orm::Database;

#[cfg(not(feature = "offset-pagination"))]
async fn main() {
test_simple_insert_one().await;
test_complex_insert_one().await;
Expand Down Expand Up @@ -620,4 +621,4 @@ async fn test_delete_mutation() {
}
"#,
);
}
}
137 changes: 137 additions & 0 deletions examples/mysql/tests/offset_pagination_query_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
use async_graphql::{dynamic::*, Response};
use sea_orm::Database;

pub async fn get_schema() -> Schema {
let database = Database::connect("mysql://sea:[email protected]/sakila")
.await
.unwrap();
let schema = seaography_mysql_example::query_root::schema(database, None, None).unwrap();

schema
}

pub fn assert_eq(a: Response, b: &str) {
assert_eq!(
a.data.into_json().unwrap(),
serde_json::from_str::<serde_json::Value>(b).unwrap()
)
}

#[cfg(feature = "offset-pagination")]
#[tokio::test]
async fn test_simple_query() {
let schema = get_schema().await;

assert_eq(
schema
.execute(
r#"
{
store {
storeId
staff {
firstName
lastName
}
}
}
"#,
)
.await,
r#"
{
"store": [
{
"storeId": 1,
"staff": {
"firstName": "Mike",
"lastName": "Hillyer"
}
},
{
"storeId": 2,
"staff": {
"firstName": "Jon",
"lastName": "Stephens"
}
}
]
}
"#,
)
}

#[cfg(feature = "offset-pagination")]
#[tokio::test]
async fn test_simple_query_with_filter() {
let schema = get_schema().await;

assert_eq(
schema
.execute(
r#"
{
store(filters: {storeId:{eq: 1}}) {
storeId
staff {
firstName
lastName
}
}
}
"#,
)
.await,
r#"
{
"store": [
{
"storeId": 1,
"staff": {
"firstName": "Mike",
"lastName": "Hillyer"
}
}
]
}
"#,
)
}

#[cfg(feature = "offset-pagination")]
#[tokio::test]
async fn test_filter_with_pagination() {
let schema = get_schema().await;

assert_eq(
schema
.execute(
r#"
{
customer(
filters: { active: { eq: 0 } }
pagination: { page: { page: 2, limit: 3 } }
) {
customerId
}
}
"#,
)
.await,
r#"
{
"customer": [
{
"customerId": 315
},
{
"customerId": 368
},
{
"customerId": 406
}
]
}
"#,
)
}
13 changes: 12 additions & 1 deletion examples/mysql/tests/query_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn assert_eq(a: Response, b: &str) {
)
}

#[cfg(not(feature = "offset-pagination"))]
#[tokio::test]
async fn test_simple_query() {
let schema = get_schema().await;
Expand Down Expand Up @@ -64,6 +65,7 @@ async fn test_simple_query() {
)
}

#[cfg(not(feature = "offset-pagination"))]
#[tokio::test]
async fn test_simple_query_with_filter() {
let schema = get_schema().await;
Expand Down Expand Up @@ -104,6 +106,7 @@ async fn test_simple_query_with_filter() {
)
}

#[cfg(not(feature = "offset-pagination"))]
#[tokio::test]
async fn test_filter_with_pagination() {
let schema = get_schema().await;
Expand Down Expand Up @@ -153,6 +156,7 @@ async fn test_filter_with_pagination() {
)
}

#[cfg(not(feature = "offset-pagination"))]
#[tokio::test]
async fn test_complex_filter_with_pagination() {
let schema = get_schema().await;
Expand Down Expand Up @@ -202,6 +206,7 @@ async fn test_complex_filter_with_pagination() {
)
}

#[cfg(not(feature = "offset-pagination"))]
#[tokio::test]
async fn test_cursor_pagination() {
let schema = get_schema().await;
Expand Down Expand Up @@ -297,6 +302,7 @@ async fn test_cursor_pagination() {
)
}

#[cfg(not(feature = "offset-pagination"))]
#[tokio::test]
async fn test_cursor_pagination_prev() {
let schema = get_schema().await;
Expand Down Expand Up @@ -374,6 +380,7 @@ async fn test_cursor_pagination_prev() {
)
}

#[cfg(not(feature = "offset-pagination"))]
#[tokio::test]
async fn test_cursor_pagination_no_next() {
let schema = get_schema().await;
Expand Down Expand Up @@ -442,6 +449,7 @@ async fn test_cursor_pagination_no_next() {
)
}

#[cfg(not(feature = "offset-pagination"))]
#[tokio::test]
async fn test_self_ref() {
let schema = get_schema().await;
Expand Down Expand Up @@ -506,6 +514,7 @@ async fn test_self_ref() {
)
}

#[cfg(not(feature = "offset-pagination"))]
#[tokio::test]
async fn related_queries_filters() {
let schema = get_schema().await;
Expand Down Expand Up @@ -696,6 +705,7 @@ async fn related_queries_filters() {
)
}

#[cfg(not(feature = "offset-pagination"))]
#[tokio::test]
async fn related_queries_pagination() {
let schema = get_schema().await;
Expand Down Expand Up @@ -833,6 +843,7 @@ async fn related_queries_pagination() {
)
}

#[cfg(not(feature = "offset-pagination"))]
#[tokio::test]
async fn enumeration_filter() {
let schema = get_schema().await;
Expand Down Expand Up @@ -884,4 +895,4 @@ async fn enumeration_filter() {
}
"#,
)
}
}
5 changes: 4 additions & 1 deletion examples/postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ features = ["with-decimal", "with-chrono", "with-postgres-array"]
[dev-dependencies]
serde_json = { version = "1.0.103" }

[features]
offset-pagination = ["seaography/offset-pagination"]

[workspace]
members = []
members = []
3 changes: 2 additions & 1 deletion examples/postgres/tests/mutation_tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use async_graphql::{dynamic::*, Response};
use sea_orm::Database;

#[cfg(not(feature = "offset-pagination"))]
#[tokio::test]
async fn main() {
test_simple_insert_one().await;
Expand Down Expand Up @@ -630,4 +631,4 @@ async fn test_delete_mutation() {
}
"#,
);
}
}
Loading