-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Seaography documentation (#58)
* Include cursor pagination * Include web API parameter
- Loading branch information
Showing
6 changed files
with
213 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,25 +15,22 @@ USAGE: | |
seaography-cli [OPTIONS] <DATABASE_URL> <CRATE_NAME> <DESTINATION> | ||
|
||
ARGS: | ||
<DATABASE_URL> | ||
<CRATE_NAME> | ||
<DESTINATION> | ||
<DATABASE_URL> [String] A valid URL pointing to the database | ||
<CRATE_NAME> [String] The cargo crate name of the generated project | ||
<DESTINATION> [String] Path pointing to the output folder, it will create it if does not exist | ||
|
||
OPTIONS: | ||
-c, --complexity-limit <COMPLEXITY_LIMIT> | ||
-d, --depth-limit <DEPTH_LIMIT> | ||
-e, --expanded-format <EXPANDED_FORMAT> | ||
-c, --complexity-limit <COMPLEXITY_LIMIT> [Number] Limit GraphQL query complexity so it cannot be greater than this number. | ||
-d, --depth-limit <DEPTH_LIMIT> [String] Limit GraphQL query depth so it cannot be greater than this number | ||
-e, --expanded-format <EXPANDED_FORMAT> [Boolean] If you want the Sea ORM Entities to be in extended format | ||
-f, --framework <FRAMEWORK> [Enum] Dictates the generator what web API framework to use. Possible values: actix, poem (default=poem) | ||
-h, --help Print help information | ||
-V, --version Print version information | ||
``` | ||
* **DATABASE_URL:** a valid URL pointing to the database. | ||
examples: `mysql://user:[email protected]:1235/database_name`, `postgres://user:[email protected]/base_name`, `sqlite://my_db.db` | ||
* **CRATE_NAME:** the cargo crate name of the generated project | ||
* **DESTINATION:** path pointing to the output folder, it will create it if does not exist | ||
* **COMPLEXITY_LIMIT:** [Number] Limit GraphQL query complexity so it cannot be greater than this number | ||
* **DEPTH_LIMIT:** [Number] Limit GraphQL query depth so it cannot be greater than this number | ||
* **EXPANDED_FORMAT:** [Boolean] If you want the Sea ORM Entities to be in [extended format](https://www.sea-ql.org/SeaORM/docs/generate-entity/expanded-entity-structure/) | ||
#### Notes | ||
* **DATABASE_URL examples:** `mysql://user:[email protected]:1235/database_name`, `postgres://user:[email protected]/base_name`, `sqlite://my_db.db` | ||
* [extended format](https://www.sea-ql.org/SeaORM/docs/generate-entity/expanded-entity-structure/) | ||
## Prerequisites | ||
|
@@ -47,9 +44,10 @@ In order to understand how the generated code works its recommended to study the | |
SeaORM is a relational ORM to help you build web services in Rust. | ||
3. [poem](https://docs.rs/crate/poem/latest) | ||
3. The web API of the generated project | ||
A full-featured and easy-to-use web framework with the Rust programming language. | ||
[poem](https://docs.rs/crate/poem/latest) | ||
[actix](https://docs.rs/crate/actix/latest) | ||
4. [tokio*](https://docs.rs/tokio/latest/tokio/) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,12 +120,12 @@ Here are the instructions on how we can generate the examples from scratch. | |
|
||
## Query examples | ||
|
||
### Fetch films and their actors | ||
#### Fetch films and their actors | ||
|
||
```graphql | ||
{ | ||
film(pagination: { limit: 10, page: 0 }, orderBy: { title: ASC }) { | ||
data { | ||
film(pagination: { pages: { limit: 2, page: 0 } }, orderBy: { title: ASC }) { | ||
nodes { | ||
title | ||
description | ||
releaseYear | ||
|
@@ -138,20 +138,86 @@ Here are the instructions on how we can generate the examples from scratch. | |
} | ||
} | ||
} | ||
``` | ||
Response | ||
```json | ||
{ | ||
"data": { | ||
"film": { | ||
"data": [ | ||
... | ||
"nodes": [ | ||
{ | ||
"title": "ACADEMY DINOSAUR", | ||
"description": "An Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies", | ||
"releaseYear": "2006", | ||
"filmActor": [ | ||
{ | ||
"actor": { | ||
"firstName": "PENELOPE", | ||
"lastName": "GUINESS" | ||
} | ||
}, | ||
{ | ||
"actor": { | ||
"firstName": "CHRISTIAN", | ||
"lastName": "GABLE" | ||
} | ||
}, | ||
{ | ||
"actor": { | ||
"firstName": "LUCILLE", | ||
"lastName": "TRACY" | ||
} | ||
}, | ||
{ | ||
"actor": { | ||
"firstName": "SANDRA", | ||
"lastName": "PECK" | ||
} | ||
}, | ||
{ | ||
"actor": { | ||
"firstName": "JOHNNY", | ||
"lastName": "CAGE" | ||
} | ||
}, | ||
{ | ||
"actor": { | ||
"firstName": "MENA", | ||
"lastName": "TEMPLE" | ||
} | ||
}, | ||
{ | ||
"actor": { | ||
"firstName": "WARREN", | ||
"lastName": "NOLTE" | ||
} | ||
}, | ||
{ | ||
"actor": { | ||
"firstName": "OPRAH", | ||
"lastName": "KILMER" | ||
} | ||
}, | ||
{ | ||
"actor": { | ||
"firstName": "ROCK", | ||
"lastName": "DUKAKIS" | ||
} | ||
}, | ||
{ | ||
"actor": { | ||
"firstName": "MARY", | ||
"lastName": "KEITEL" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"title": "ACE GOLDFINGER", | ||
"description": "A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China", | ||
"releaseYear": 2006, | ||
"releaseYear": "2006", | ||
"filmActor": [ | ||
{ | ||
"actor": { | ||
|
@@ -178,20 +244,19 @@ Response | |
} | ||
} | ||
] | ||
}, | ||
... | ||
} | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
### Fetch store and its employee | ||
#### Fetch store and its employee | ||
```graphql | ||
{ | ||
store(filters: { storeId: { eq: 1 } }) { | ||
data { | ||
nodes { | ||
storeId | ||
address { | ||
address | ||
|
@@ -212,7 +277,7 @@ Response | |
{ | ||
"data": { | ||
"store": { | ||
"data": [ | ||
"nodes": [ | ||
{ | ||
"storeId": 1, | ||
"address": { | ||
|
@@ -234,8 +299,11 @@ Response | |
```graphql | ||
{ | ||
customer(filters: { active: { eq: 0 } }, pagination: { page: 2, limit: 3 }) { | ||
data { | ||
customer( | ||
filters: { active: { eq: 0 } } | ||
pagination: { pages: { page: 2, limit: 3 } } | ||
) { | ||
nodes { | ||
customerId | ||
lastName | ||
|
@@ -252,7 +320,7 @@ Response | |
{ | ||
"data": { | ||
"customer": { | ||
"data": [ | ||
"nodes": [ | ||
{ | ||
"customerId": 315, | ||
"lastName": "GOODEN", | ||
|
@@ -276,21 +344,24 @@ Response | |
} | ||
``` | ||
### Fetch expensive orders and customer data | ||
### The query above using cursor pagination | ||
```graphql | ||
{ | ||
payment(filters: { amount: { gt: "11.1" } }) { | ||
data { | ||
paymentId | ||
amount | ||
customer { | ||
lastName | ||
} | ||
customer( | ||
filters: { active: { eq: 0 } } | ||
pagination: { cursor: { limit: 3, cursor: "Int[3]:271" } } | ||
) { | ||
nodes { | ||
customerId | ||
lastName | ||
} | ||
pageInfo { | ||
hasPreviousPage | ||
hasNextPage | ||
endCursor | ||
} | ||
pages | ||
current | ||
} | ||
} | ||
``` | ||
|
@@ -300,36 +371,29 @@ Response | |
```json | ||
{ | ||
"data": { | ||
"payment": { | ||
"data": [ | ||
"customer": { | ||
"nodes": [ | ||
{ | ||
"paymentId": 342, | ||
"amount": "11.99", | ||
"customer": { | ||
"lastName": "JACKSON", | ||
"email": "[email protected]" | ||
} | ||
"customerId": 315, | ||
"lastName": "GOODEN", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"paymentId": 3146, | ||
"amount": "11.99", | ||
"customer": { | ||
"lastName": "GIBSON", | ||
"email": "[email protected]" | ||
} | ||
"customerId": 368, | ||
"lastName": "ARCE", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"paymentId": 5280, | ||
"amount": "11.99", | ||
"customer": { | ||
"lastName": "SIMS", | ||
"email": "[email protected]" | ||
} | ||
}, | ||
... | ||
"customerId": 406, | ||
"lastName": "RUNYON", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"pages": 1, | ||
"current": 1 | ||
"pageInfo": { | ||
"hasPreviousPage": true, | ||
"hasNextPage": true, | ||
"endCursor": "Int[3]:406" | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ You can perform the following query | |
```graphql | ||
{ | ||
category { | ||
data { | ||
nodes { | ||
id, | ||
name, | ||
product { | ||
|
Oops, something went wrong.