Skip to content

Latest commit

 

History

History

seaography_example

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

SeaORM + Seaography Example

Seaography screenshot with Bakery schema
The Bakery schema

Specifiy a database url

export DATABASE_URL=mysql:https://sea:sea@localhost/bakery

Setup the Database

Cd into migration folder and follow instructions there, but basically:

cargo run

Install Seaography

cargo install seaography-cli@^1.0.0-rc.3

Generate GraphQL project

rm -rf graphql # this entire folder is generated
sea-orm-cli generate entity --output-dir graphql/src/entities --seaography
seaography-cli graphql graphql/src/entities $DATABASE_URL sea-orm-seaography-example

Running the project

cd graphql
cargo run

Run some queries

Bakery -> Cake -> Baker

{
  bakery(pagination: { page: { limit: 10, page: 0 } }, orderBy: { name: ASC }) {
    nodes {
      name
      cake {
        nodes {
          name
          price
          baker {
            nodes {
              name
            }
          }
        }
      }
    }
  }
}

List gluten-free cakes and know where to buy them

{
  cake(filters: { glutenFree: { eq: 1 } }) {
    nodes {
      name
      price
      glutenFree
      bakery {
        name
      }
    }
  }
}