Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

SeaORM + Seaography Example

Seaography screenshot with Bakery schema
The Bakery schema

Running the project

Specify a database url

export DATABASE_URL="sqlite://../bakery.db"

Then, run

cd graphql
cargo run

Run some queries

Find chocolate cakes and know where to buy them

{
  cake(filters: { name: { contains: "Chocolate" } }) {
    nodes {
      name
      price
      bakery {
        name
      }
    }
  }
}

Find all cakes baked by Alice

{
  cake(having: { baker: { name: { eq: "Alice" } } }) {
    nodes {
      name
      price
      baker {
        nodes {
          name
        }
      }
    }
  }
}

Bakery -> Cake -> Baker

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

Starting from scratch

Setup the Database

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

export DATABASE_URL="sqlite://../bakery.db?mode=rwc"
cd migration
cargo run

Install Seaography

cargo install sea-orm-cli@^2.0.0-rc
cargo install seaography-cli@^2.0.0-rc

Generate GraphQL project

rm -rf graphql # this entire folder is generated
mkdir graphql
cd graphql
sea-orm-cli generate entity --output-dir ./src/entities --entity-format dense --seaography
seaography-cli -o . -e ./src/entities --framework axum sea-orm-seaography-example