Skip to content

Commit

Permalink
Merge branch 'main' into mutations-update
Browse files Browse the repository at this point in the history
  • Loading branch information
karatakis committed Jul 28, 2023
2 parents f12ecb9 + 058a661 commit 41ba2c7
Show file tree
Hide file tree
Showing 42 changed files with 403 additions and 91 deletions.
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.0.2 - 2023-03-25

## 1.0.3 - pending
* add `update_mutation` to allow the Update mutation. The mutation takes entity data and filter condition, updates the entities and returns the updated result

## 1.0.2 - pending

* add `create_one_mutation`

Expand Down Expand Up @@ -41,19 +45,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

* start error handling

## 1.0.1 - 2023-03-25
## 1.0.1 - pending

* slim down code generation for the `query_root.rs` file of a generated project

* update crates

* update examples

## 1.0.0 - 2023-03-25
## 1.0.0 - Pending

`1.0.0-rc.1`: 2023-07-28

Introduction the functional API of Seaography. Warning, this version has breaking changes, but it was a sacrifice in order to make the project easier to maintain. With this version we have support for field guards and field renames.

### Breaking changes

* Dropped the derive API in favor of a functional API

SeaORM is a dynamic ORM for rust, this means that we can inspect the Tables, Columns properties on runtime. Recently async-graphql added support for dynamic creation of GraphQL nodes. Utilizing the dynamic nature of both libraries the Derive API is no longer needed and we developed a functional approach API. Moreover, the project in order to live long it needs to be maintainable (easy to maintain) and extensible (easy to extend), but the Derive API was fairly complex compared to a functional API. In order to make the migration easier we updated the seaography generator to generate using the new API
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [

[package]
name = "seaography"
version = "1.0.0"
version = "1.0.0-rc.1"
edition = "2021"
rust-version = "1.60"
authors = ["Panagiotis Karatakis <panagiotiskaratakis@gmail.com>"]
Expand All @@ -21,7 +21,7 @@ categories = ["database"]

[dependencies]
async-graphql = { version = "5.0.10", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] }
sea-orm = { version = "0.12.0-rc.5", default-features = false, features = ["seaography"] }
sea-orm = { version = "0.12.0", default-features = false, features = ["seaography"] }
itertools = { version = "0.11.0" }
heck = { version = "0.4.1" }
thiserror = "1.0.44"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
### Install

```sh
cargo install sea-orm-cli # used to generate entities
cargo install seaography-cli
cargo install sea-orm-cli@^0.12 # used to generate entities
cargo install seaography-cli@1
```

### MySQL
Expand Down
2 changes: 0 additions & 2 deletions build-tools/cargo-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ set -e
cd generator
cargo publish
cd ..
sleep 10

cd cli
cargo publish
cd ..
sleep 10

cargo publish
4 changes: 2 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "seaography-cli"
version = "1.0.0"
version = "1.0.0-rc.1"
edition = "2021"
rust-version = "1.60"
authors = ["Panagiotis Karatakis <panagiotiskaratakis@gmail.com>"]
Expand All @@ -15,5 +15,5 @@ categories = ["database"]
[dependencies]
async-std = { version = "1.12.0", features = [ "attributes", "tokio1" ] }
clap = { version = "4.3.19", features = ["derive"] }
seaography-generator = { version = "^1.0.0", path = "../generator" }
seaography-generator = { version = "^1.0.0-rc.1", path = "../generator" }
url = "2.4.0"
10 changes: 5 additions & 5 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ use seaography_generator::write_project;
#[derive(clap::Parser)]
#[clap(author, version, about, long_about = None)]
pub struct Args {
/// project destination folder
/// Project destination folder
pub destination: String,

/// entities folder to depend on
/// SeaORM entities folder
pub entities: String,

/// database URL to write it in .env
/// Database URL to write in .env
pub database_url: String,

/// crate name for generated project
/// Crate name for generated project
pub crate_name: String,

/// web framework
/// Which web framework to use
#[clap(short, long, value_enum, default_value_t = WebFrameworkEnum::Poem)]
pub framework: WebFrameworkEnum,

Expand Down
4 changes: 2 additions & 2 deletions examples/mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ async-graphql-poem = { version = "5.0.10" }
async-graphql = { version = "5.0.10", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] }
async-trait = { version = "0.1.72" }
dotenv = "0.15.0"
sea-orm = { version = "0.12.0-rc.5", features = ["sqlx-mysql", "runtime-async-std-native-tls", "seaography"] }
sea-orm = { version = "0.12.0", features = ["sqlx-mysql", "runtime-async-std-native-tls", "seaography"] }
tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] }
tracing = { version = "0.1.37" }
tracing-subscriber = { version = "0.3.17" }
lazy_static = { version = "1.4.0" }

[dependencies.seaography]
path = "../../"
version = "^1.0.0" # seaography version
version = "^1.0.0-rc.1" # seaography version
features = ["with-decimal", "with-chrono"]

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/actor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/address.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/category.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/city.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/country.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
4 changes: 2 additions & 2 deletions examples/mysql/src/entities/customer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand All @@ -14,7 +14,7 @@ pub struct Model {
pub address_id: i32,
pub active: i8,
pub create_date: DateTime,
pub last_update: DateTimeUtc,
pub last_update: Option<DateTimeUtc>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/film.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use super::sea_orm_active_enums::Rating;
use sea_orm::entity::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/film_actor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/film_category.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/film_text.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/inventory.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/language.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

pub mod prelude;

Expand Down
4 changes: 2 additions & 2 deletions examples/mysql/src/entities/payment.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand All @@ -13,7 +13,7 @@ pub struct Model {
#[sea_orm(column_type = "Decimal(Some((5, 2)))")]
pub amount: Decimal,
pub payment_date: DateTime,
pub last_update: DateTimeUtc,
pub last_update: Option<DateTimeUtc>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

pub use super::actor::Entity as Actor;
pub use super::address::Entity as Address;
Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/rental.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/sea_orm_active_enums.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/staff.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/entities/store.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.0-rc.5
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1

use sea_orm::entity::prelude::*;

Expand Down
22 changes: 11 additions & 11 deletions examples/mysql/src/query_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ pub fn schema(
seaography::register_entities!(
builder,
[
film_actor,
rental,
actor,
address,
category,
staff,
city,
country,
customer,
film,
actor,
language,
city,
inventory,
film_text,
film_actor,
film_category,
customer,
store,
film_text,
inventory,
language,
payment,
address,
rental,
staff,
store,
]
);
builder.register_enumeration::<crate::entities::sea_orm_active_enums::Rating>();
Expand Down
81 changes: 81 additions & 0 deletions examples/mysql/tests/query_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,87 @@ async fn related_queries_filters() {
}
}
"#,
);

assert_eq(
schema
.execute(
r#"
{
film(filters:{filmId: {eq: 1}}) {
nodes {
title
description
releaseYear
actor {
nodes {
firstName
lastName
}
}
}
}
}
"#,
)
.await,
r#"
{
"film": {
"nodes": [
{
"title": "ACADEMY DINOSAUR",
"description": "A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies",
"releaseYear": 2006,
"actor": {
"nodes": [
{
"firstName": "PENELOPE",
"lastName": "GUINESS"
},
{
"firstName": "CHRISTIAN",
"lastName": "GABLE"
},
{
"firstName": "LUCILLE",
"lastName": "TRACY"
},
{
"firstName": "SANDRA",
"lastName": "PECK"
},
{
"firstName": "JOHNNY",
"lastName": "CAGE"
},
{
"firstName": "MENA",
"lastName": "TEMPLE"
},
{
"firstName": "WARREN",
"lastName": "NOLTE"
},
{
"firstName": "OPRAH",
"lastName": "KILMER"
},
{
"firstName": "ROCK",
"lastName": "DUKAKIS"
},
{
"firstName": "MARY",
"lastName": "KEITEL"
}
]
}
}
]
}
}
"#,
)
}

Expand Down
Loading

0 comments on commit 41ba2c7

Please sign in to comment.