Skip to content

feature/offset-pagination #174

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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e86172c
first commit
Sep 11, 2024
5a856ee
fix unitests and code style
Sep 12, 2024
d46567b
use convenient sea-orm version
MedHeikelBouzayene Oct 15, 2024
249ddf1
add cascade
MedHeikelBouzayene Oct 16, 2024
35468c9
make filter close to dgraph, and improve the cascade to work when we …
MedHeikelBouzayene Oct 18, 2024
61a2ca8
test: check webhook
MedHeikelBouzayene Oct 26, 2024
8a8585e
test: check webhook
MedHeikelBouzayene Oct 26, 2024
74daa41
feat: make discord notification as discord action
MedHeikelBouzayene Oct 26, 2024
18941bf
feat: add first for the queries, add getEntity, and change is_in to in
MedHeikelBouzayene Nov 7, 2024
5c44350
feat: add not in the filter
MedHeikelBouzayene Nov 7, 2024
4f79dc2
fix: Enum values
MedHeikelBouzayene Nov 9, 2024
cc2dbda
fix: Enum values
MedHeikelBouzayene Nov 9, 2024
f6d5c2c
feat: add order like dgraph, and correct first
MedHeikelBouzayene Nov 10, 2024
e20c81f
fix: put cascade on hold
MedHeikelBouzayene Nov 10, 2024
242c712
fix: put cascade on hold
MedHeikelBouzayene Nov 10, 2024
e50c929
fix: remove non-alphanumeric from enums
MedHeikelBouzayene Nov 10, 2024
5f9319a
fix: filter
MedHeikelBouzayene Nov 12, 2024
b4c6254
fix: merge main into my branch
MedHeikelBouzayene Nov 20, 2024
2c78a46
chore: update to latest version of seaography
MedHeikelBouzayene Nov 20, 2024
5212e47
fix: merge main
MedHeikelBouzayene Dec 16, 2024
249902f
feat: add interface
MedHeikelBouzayene Jan 9, 2025
32119a0
fix: sea-orm version
MedHeikelBouzayene Jan 13, 2025
e23746e
fix: map in connection object
MedHeikelBouzayene Jan 19, 2025
98aa587
Merge pull request #2 from sambaclab/feat/add_interface
MedHeikelBouzayene Jan 21, 2025
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
12 changes: 10 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ keywords = ["async", "graphql", "mysql", "postgres", "sqlite"]
categories = ["database"]

[dependencies]
async-graphql = { version = "7.0", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] }
sea-orm = { version = "~1.1.0", default-features = false, features = ["seaography"] }
async-graphql = { version = "7.0", features = [
"decimal",
"chrono",
"dataloader",
"dynamic-schema",
] }
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,6 +39,7 @@ 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"]
field-snake-case = []
Expand Down
214 changes: 109 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<strong>🧭 A GraphQL framework and code generator for SeaORM</strong>
</p>

[![crate](https://img.shields.io/crates/v/seaography.svg)](https://crates.io/crates/seaography)
[![docs](https://docs.rs/seaography/badge.svg)](https://docs.rs/seaography)
[![build status](https://github.com/SeaQL/seaography/actions/workflows/tests.yaml/badge.svg)](https://github.com/SeaQL/seaography/actions/workflows/tests.yaml)
[![crate](https://img.shields.io/crates/v/seaography.svg)](https://crates.io/crates/seaography)
[![docs](https://docs.rs/seaography/badge.svg)](https://docs.rs/seaography)
[![build status](https://github.com/SeaQL/seaography/actions/workflows/tests.yaml/badge.svg)](https://github.com/SeaQL/seaography/actions/workflows/tests.yaml)

</div>

Expand All @@ -18,27 +18,27 @@

## Benefits

* Quick and easy to get started
* Generates readable code
* Extensible project structure
* Based on popular async libraries: [async-graphql](https://github.com/async-graphql/async-graphql) and [SeaORM](https://github.com/SeaQL/sea-orm)
- Quick and easy to get started
- Generates readable code
- Extensible project structure
- Based on popular async libraries: [async-graphql](https://github.com/async-graphql/async-graphql) and [SeaORM](https://github.com/SeaQL/sea-orm)

## Features

* Relational query (1-to-1, 1-to-N)
* Pagination for queries and relations (1-N)
* Filtering with operators (e.g. gt, lt, eq)
* Order by any column
* Guard fields, queries or relations
* Rename fields
* Mutations (create, update, delete)
- Relational query (1-to-1, 1-to-N)
- Pagination for queries and relations (1-N)
- Filtering with operators (e.g. gt, lt, eq)
- Order by any column
- Guard fields, queries or relations
- Rename fields
- Mutations (create, update, delete)

(Right now there is no mutation, but it's on our plan!)

## SeaORM Version Compatibility

| Seaography | SeaORM |
|----------------------------------------------------------|-------------------------------------------------------|
| Seaography | SeaORM |
| -------------------------------------------------------- | ----------------------------------------------------- |
| [1.1-rc](https://crates.io/crates/seaography/1.1.0-rc.1) | [1.1-rc](https://crates.io/crates/sea-orm/1.1.0-rc.1) |
| [1.0](https://crates.io/crates/seaography/1.0.0) | [1.0](https://crates.io/crates/sea-orm/1.0.0) |
| [0.12](https://crates.io/crates/seaography/0.12.0) | [0.12](https://crates.io/crates/sea-orm/0.12.14) |
Expand Down Expand Up @@ -70,82 +70,85 @@ Go to http://localhost:8000/ and try out the following queries:

```graphql
{
film(pagination: { page: { limit: 10, page: 0 } }, orderBy: { title: ASC }) {
nodes {
title
description
releaseYear
actor {
film(
pagination: { page: { limit: 10, page: 0 } }
orderBy: { title: ASC }
) {
nodes {
firstName
lastName
title
description
releaseYear
actor {
nodes {
firstName
lastName
}
}
}
}
}
}
}
```

#### Fetch store and its employee

```graphql
{
store(filters: { storeId: { eq: 1 } }) {
nodes {
storeId
address {
address
address2
}
staff {
firstName
lastName
}
store(filters: { storeId: { eq: 1 } }) {
nodes {
storeId
address {
address
address2
}
staff {
firstName
lastName
}
}
}
}
}
```

### Fetch inactive customers with pagination

```graphql
{
customer(
filters: { active: { eq: 0 } }
pagination: { page: { page: 2, limit: 3 } }
) {
nodes {
customerId
lastName
email
}
paginationInfo {
pages
current
customer(
filters: { active: { eq: 0 } }
pagination: { page: { page: 2, limit: 3 } }
) {
nodes {
customerId
lastName
email
}
paginationInfo {
pages
current
}
}
}
}
```

### The query above using cursor pagination

```graphql
{
customer(
filters: { active: { eq: 0 } }
pagination: { cursor: { limit: 3, cursor: "Int[3]:271" } }
) {
nodes {
customerId
lastName
email
}
pageInfo {
hasPreviousPage
hasNextPage
endCursor
customer(
filters: { active: { eq: 0 } }
pagination: { cursor: { limit: 3, cursor: "Int[3]:271" } }
) {
nodes {
customerId
lastName
email
}
pageInfo {
hasPreviousPage
hasNextPage
endCursor
}
}
}
}
```

Expand All @@ -155,57 +158,58 @@ Find all inactive customers, include their address, and their payments with amou

```graphql
{
customer(
filters: { active: { eq: 0 } }
pagination: { cursor: { limit: 3, cursor: "Int[3]:271" } }
) {
nodes {
customerId
lastName
email
address {
address
}
payment(
filters: { amount: { gt: "7" } }
orderBy: { amount: ASC }
pagination: { page: { limit: 1, page: 1 } }
) {
customer(
filters: { active: { eq: 0 } }
pagination: { cursor: { limit: 3, cursor: "Int[3]:271" } }
) {
nodes {
paymentId
amount
}
paginationInfo {
pages
current
customerId
lastName
email
address {
address
}
payment(
filters: { amount: { gt: "7" } }
orderBy: { amount: ASC }
pagination: { page: { limit: 1, page: 1 } }
) {
nodes {
paymentId
amount
}
paginationInfo {
pages
current
}
pageInfo {
hasPreviousPage
hasNextPage
}
}
}
pageInfo {
hasPreviousPage
hasNextPage
hasPreviousPage
hasNextPage
endCursor
}
}
}
pageInfo {
hasPreviousPage
hasNextPage
endCursor
}
}
}
```

### Filter using enumeration

```graphql
{
film(
filters: { rating: { eq: NC17 } }
pagination: { page: { page: 1, limit: 5 } }
) {
nodes {
filmId
rating
film(
filters: { rating: { eq: NC17 } }
pagination: { page: { page: 1, limit: 5 } }
) {
nodes {
filmId
rating
}
}
}
}
```

Expand Down Expand Up @@ -233,4 +237,4 @@ cargo run

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Seaography is a community driven project. We welcome you to participate, contribute and together build for Rust's future.
Seaography is a community driven project. We welcome you to participate, contribute and together build for Rust's future.
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() {
}
"#,
);
}
}
Loading