Skip to content

Commit

Permalink
Update github actions
Browse files Browse the repository at this point in the history
* update mysql example
* update postgres example
  • Loading branch information
karatakis committed Aug 8, 2022
1 parent 8e9744a commit e4362ec
Show file tree
Hide file tree
Showing 44 changed files with 236,342 additions and 47,208 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/quality_assurance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,17 @@ jobs:
- name: Remove generated folder
run: rm -rf ./examples/postgres/src
- name: Create DB
run: psql -q postgres://sea:sea@localhost/postgres -c 'CREATE DATABASE "dvdrental"'
run: psql -q postgres://sea:sea@localhost/postgres -c 'CREATE DATABASE "sakila"'
- name: Import DB Schema
run: psql -q postgres://sea:sea@localhost/dvdrental < dvdrental-schema.sql
run: psql -q postgres://sea:sea@localhost/sakila < sakila-schema.sql
working-directory: ./examples/postgres
- name: Import DB Data
run: psql -q postgres://sea:sea@localhost/dvdrental < dvdrental-data.sql
run: psql -q postgres://sea:sea@localhost/sakila < sakila-data.sql
working-directory: ./examples/postgres
- uses: actions-rs/cargo@v1
with:
command: run
args: "postgres://sea:[email protected]/dvdrental?currentSchema=public generated ./examples/postgres"
args: "postgres://sea:[email protected]/sakila?currentSchema=public generated ./examples/postgres"
- name: Integration tests
working-directory: ./examples/postgres
run: cargo test
106 changes: 53 additions & 53 deletions examples/mysql/src/graphql/entities/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,47 +331,47 @@ impl Model {
pub async fn last_update(&self) -> &DateTimeUtc {
&self.last_update
}
pub async fn address_address_customer<'a>(
pub async fn address_address_store<'a>(
&self,
ctx: &async_graphql::Context<'a>,
) -> Vec<crate::orm::customer::Model> {
) -> Vec<crate::orm::store::Model> {
let data_loader = ctx
.data::<async_graphql::dataloader::DataLoader<OrmDataloader>>()
.unwrap();
let key = AddressCustomerFK(self.address_id.clone().try_into().unwrap());
let key = AddressStoreFK(self.address_id.clone().try_into().unwrap());
let data: Option<_> = data_loader.load_one(key).await.unwrap();
data.unwrap_or(vec![])
}
pub async fn address_city_city<'a>(
pub async fn address_address_staff<'a>(
&self,
ctx: &async_graphql::Context<'a>,
) -> crate::orm::city::Model {
) -> Vec<crate::orm::staff::Model> {
let data_loader = ctx
.data::<async_graphql::dataloader::DataLoader<OrmDataloader>>()
.unwrap();
let key = CityCityFK(self.city_id.clone().try_into().unwrap());
let key = AddressStaffFK(self.address_id.clone().try_into().unwrap());
let data: Option<_> = data_loader.load_one(key).await.unwrap();
data.unwrap()
data.unwrap_or(vec![])
}
pub async fn address_address_store<'a>(
pub async fn address_city_city<'a>(
&self,
ctx: &async_graphql::Context<'a>,
) -> Vec<crate::orm::store::Model> {
) -> crate::orm::city::Model {
let data_loader = ctx
.data::<async_graphql::dataloader::DataLoader<OrmDataloader>>()
.unwrap();
let key = AddressStoreFK(self.address_id.clone().try_into().unwrap());
let key = CityCityFK(self.city_id.clone().try_into().unwrap());
let data: Option<_> = data_loader.load_one(key).await.unwrap();
data.unwrap_or(vec![])
data.unwrap()
}
pub async fn address_address_staff<'a>(
pub async fn address_address_customer<'a>(
&self,
ctx: &async_graphql::Context<'a>,
) -> Vec<crate::orm::staff::Model> {
) -> Vec<crate::orm::customer::Model> {
let data_loader = ctx
.data::<async_graphql::dataloader::DataLoader<OrmDataloader>>()
.unwrap();
let key = AddressStaffFK(self.address_id.clone().try_into().unwrap());
let key = AddressCustomerFK(self.address_id.clone().try_into().unwrap());
let data: Option<_> = data_loader.load_one(key).await.unwrap();
data.unwrap_or(vec![])
}
Expand All @@ -392,21 +392,19 @@ pub struct Filter {
pub last_update: Option<TypeFilter<DateTimeUtc>>,
}
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct AddressCustomerFK(u16);
pub struct AddressStoreFK(u16);
#[async_trait::async_trait]
impl async_graphql::dataloader::Loader<AddressCustomerFK> for OrmDataloader {
type Value = Vec<crate::orm::customer::Model>;
impl async_graphql::dataloader::Loader<AddressStoreFK> for OrmDataloader {
type Value = Vec<crate::orm::store::Model>;
type Error = std::sync::Arc<sea_orm::error::DbErr>;
async fn load(
&self,
keys: &[AddressCustomerFK],
) -> Result<std::collections::HashMap<AddressCustomerFK, Self::Value>, Self::Error> {
keys: &[AddressStoreFK],
) -> Result<std::collections::HashMap<AddressStoreFK, Self::Value>, Self::Error> {
let filter = sea_orm::Condition::all().add(sea_orm::sea_query::SimpleExpr::Binary(
Box::new(sea_orm::sea_query::SimpleExpr::Tuple(vec![
sea_orm::sea_query::Expr::col(
crate::orm::customer::Column::AddressId.as_column_ref(),
)
.into_simple_expr(),
sea_orm::sea_query::Expr::col(crate::orm::store::Column::AddressId.as_column_ref())
.into_simple_expr(),
])),
sea_orm::sea_query::BinOper::In,
Box::new(sea_orm::sea_query::SimpleExpr::Tuple(
Expand All @@ -418,31 +416,31 @@ impl async_graphql::dataloader::Loader<AddressCustomerFK> for OrmDataloader {
)),
));
use itertools::Itertools;
Ok(crate::orm::customer::Entity::find()
Ok(crate::orm::store::Entity::find()
.filter(filter)
.all(&self.db)
.await?
.into_iter()
.map(|model| {
let key = AddressCustomerFK(model.address_id.clone().try_into().unwrap());
let key = AddressStoreFK(model.address_id.clone().try_into().unwrap());
(key, model)
})
.into_group_map())
}
}
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct CityCityFK(u16);
pub struct AddressStaffFK(u16);
#[async_trait::async_trait]
impl async_graphql::dataloader::Loader<CityCityFK> for OrmDataloader {
type Value = crate::orm::city::Model;
impl async_graphql::dataloader::Loader<AddressStaffFK> for OrmDataloader {
type Value = Vec<crate::orm::staff::Model>;
type Error = std::sync::Arc<sea_orm::error::DbErr>;
async fn load(
&self,
keys: &[CityCityFK],
) -> Result<std::collections::HashMap<CityCityFK, Self::Value>, Self::Error> {
keys: &[AddressStaffFK],
) -> Result<std::collections::HashMap<AddressStaffFK, Self::Value>, Self::Error> {
let filter = sea_orm::Condition::all().add(sea_orm::sea_query::SimpleExpr::Binary(
Box::new(sea_orm::sea_query::SimpleExpr::Tuple(vec![
sea_orm::sea_query::Expr::col(crate::orm::city::Column::CityId.as_column_ref())
sea_orm::sea_query::Expr::col(crate::orm::staff::Column::AddressId.as_column_ref())
.into_simple_expr(),
])),
sea_orm::sea_query::BinOper::In,
Expand All @@ -454,31 +452,32 @@ impl async_graphql::dataloader::Loader<CityCityFK> for OrmDataloader {
.collect(),
)),
));
Ok(crate::orm::city::Entity::find()
use itertools::Itertools;
Ok(crate::orm::staff::Entity::find()
.filter(filter)
.all(&self.db)
.await?
.into_iter()
.map(|model| {
let key = CityCityFK(model.city_id.clone().try_into().unwrap());
let key = AddressStaffFK(model.address_id.clone().try_into().unwrap());
(key, model)
})
.collect())
.into_group_map())
}
}
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct AddressStoreFK(u16);
pub struct CityCityFK(u16);
#[async_trait::async_trait]
impl async_graphql::dataloader::Loader<AddressStoreFK> for OrmDataloader {
type Value = Vec<crate::orm::store::Model>;
impl async_graphql::dataloader::Loader<CityCityFK> for OrmDataloader {
type Value = crate::orm::city::Model;
type Error = std::sync::Arc<sea_orm::error::DbErr>;
async fn load(
&self,
keys: &[AddressStoreFK],
) -> Result<std::collections::HashMap<AddressStoreFK, Self::Value>, Self::Error> {
keys: &[CityCityFK],
) -> Result<std::collections::HashMap<CityCityFK, Self::Value>, Self::Error> {
let filter = sea_orm::Condition::all().add(sea_orm::sea_query::SimpleExpr::Binary(
Box::new(sea_orm::sea_query::SimpleExpr::Tuple(vec![
sea_orm::sea_query::Expr::col(crate::orm::store::Column::AddressId.as_column_ref())
sea_orm::sea_query::Expr::col(crate::orm::city::Column::CityId.as_column_ref())
.into_simple_expr(),
])),
sea_orm::sea_query::BinOper::In,
Expand All @@ -490,33 +489,34 @@ impl async_graphql::dataloader::Loader<AddressStoreFK> for OrmDataloader {
.collect(),
)),
));
use itertools::Itertools;
Ok(crate::orm::store::Entity::find()
Ok(crate::orm::city::Entity::find()
.filter(filter)
.all(&self.db)
.await?
.into_iter()
.map(|model| {
let key = AddressStoreFK(model.address_id.clone().try_into().unwrap());
let key = CityCityFK(model.city_id.clone().try_into().unwrap());
(key, model)
})
.into_group_map())
.collect())
}
}
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct AddressStaffFK(u16);
pub struct AddressCustomerFK(u16);
#[async_trait::async_trait]
impl async_graphql::dataloader::Loader<AddressStaffFK> for OrmDataloader {
type Value = Vec<crate::orm::staff::Model>;
impl async_graphql::dataloader::Loader<AddressCustomerFK> for OrmDataloader {
type Value = Vec<crate::orm::customer::Model>;
type Error = std::sync::Arc<sea_orm::error::DbErr>;
async fn load(
&self,
keys: &[AddressStaffFK],
) -> Result<std::collections::HashMap<AddressStaffFK, Self::Value>, Self::Error> {
keys: &[AddressCustomerFK],
) -> Result<std::collections::HashMap<AddressCustomerFK, Self::Value>, Self::Error> {
let filter = sea_orm::Condition::all().add(sea_orm::sea_query::SimpleExpr::Binary(
Box::new(sea_orm::sea_query::SimpleExpr::Tuple(vec![
sea_orm::sea_query::Expr::col(crate::orm::staff::Column::AddressId.as_column_ref())
.into_simple_expr(),
sea_orm::sea_query::Expr::col(
crate::orm::customer::Column::AddressId.as_column_ref(),
)
.into_simple_expr(),
])),
sea_orm::sea_query::BinOper::In,
Box::new(sea_orm::sea_query::SimpleExpr::Tuple(
Expand All @@ -528,13 +528,13 @@ impl async_graphql::dataloader::Loader<AddressStaffFK> for OrmDataloader {
)),
));
use itertools::Itertools;
Ok(crate::orm::staff::Entity::find()
Ok(crate::orm::customer::Entity::find()
.filter(filter)
.all(&self.db)
.await?
.into_iter()
.map(|model| {
let key = AddressStaffFK(model.address_id.clone().try_into().unwrap());
let key = AddressCustomerFK(model.address_id.clone().try_into().unwrap());
(key, model)
})
.into_group_map())
Expand Down
Loading

0 comments on commit e4362ec

Please sign in to comment.