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

Update Seaography documentation #58

Merged
merged 1 commit into from
Nov 1, 2022
Merged
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
28 changes: 13 additions & 15 deletions Seaography/docs/01-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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/)

Expand Down
164 changes: 114 additions & 50 deletions Seaography/docs/02-running-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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": {
Expand All @@ -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
Expand All @@ -212,7 +277,7 @@ Response
{
"data": {
"store": {
"data": [
"nodes": [
{
"storeId": 1,
"address": {
Expand All @@ -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
email
Expand All @@ -252,7 +320,7 @@ Response
{
"data": {
"customer": {
"data": [
"nodes": [
{
"customerId": 315,
"lastName": "GOODEN",
Expand All @@ -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
email
}
customer(
filters: { active: { eq: 0 } }
pagination: { cursor: { limit: 3, cursor: "Int[3]:271" } }
) {
nodes {
customerId
lastName
email
}
pageInfo {
hasPreviousPage
hasNextPage
endCursor
}
pages
current
}
}
```
Expand All @@ -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"
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Seaography/docs/04-extending-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ You can perform the following query
```graphql
{
category {
data {
nodes {
id,
name,
product {
Expand Down
Loading