Skip to content

Commit 4fcc10b

Browse files
committed
More WIP
1 parent 74584fc commit 4fcc10b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2299
-2919
lines changed

wundergraph/Cargo.toml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,32 @@ uuid = { version = "0.7", optional = true }
1616
chrono = { version = "0.4", optional = true }
1717
failure = "0.1"
1818
log = "0.4"
19+
paste = "0.1"
1920

2021
[dev-dependencies]
2122
wundergraph_example = { path = "../wundergraph_example", default-features = false, features = ["postgres"] }
22-
#wundergraph_bench = { path = "../wundergraph_bench" }
23+
wundergraph_bench = { path = "../wundergraph_bench" }
2324
diesel_migrations = "1.3.0"
2425
serde_json = "1"
2526
criterion = "0.2"
2627
lazy_static = "1"
2728

2829
[features]
29-
#default = []
30-
default = ["postgres", "sqlite", "extras"]
30+
default = ["postgres"]
31+
#default = ["postgres", "extras"]
3132
debug = ["wundergraph_derive/debug"]
3233
sqlite = ["diesel/sqlite", "wundergraph_derive/sqlite"]
3334
postgres = ["diesel/postgres", "wundergraph_derive/postgres"]
3435
extras = ["chrono", "uuid"]
3536

3637

3738

38-
#[[test]]
39-
#name = "integration_tests"
40-
#path = "tests/lib.rs"
41-
#harness = true
39+
[[test]]
40+
name = "integration_tests"
41+
path = "tests/lib.rs"
42+
harness = true
4243

43-
#[[bench]]
44-
#name = "queries"
45-
#path = "bench/queries.rs"
46-
#harness = false
44+
[[bench]]
45+
name = "queries"
46+
path = "bench/queries.rs"
47+
harness = false

wundergraph/bench/queries.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ const QUERIES: &[&str] = &[
7474
}
7575
}
7676
}"#,
77-
// r#"query artists_collaboration {
78-
// Artists(filter: {albums: {tracks: {composer: {eq: "Ludwig van Beethoven"}}}})
79-
// {
80-
// id
81-
// name
82-
// }
83-
//}"#,
77+
// r#"query artists_collaboration {
78+
// Artists(filter: {albums: {tracks: {composer: {eq: "Ludwig van Beethoven"}}}})
79+
// {
80+
// id
81+
// name
82+
// }
83+
//}"#,
8484
r#"query artistByArtistId {
8585
Artists(filter: {id: {eq:3}}) {
8686
id

wundergraph/src/error.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! This module contains all error handling related functionality in wundergraph
22
3+
use crate::scalar::WundergraphScalarValue;
4+
35
/// The main error type of wundergraph
46
#[derive(Debug, Fail)]
57
pub enum WundergraphError {
@@ -16,4 +18,8 @@ pub enum WundergraphError {
1618
},
1719
#[fail(display = "Could not build primary key filter from arguments")]
1820
NoPrimaryKeyArgumentFound,
21+
#[fail(display = "Failed to build a return value")]
22+
JuniperError {
23+
inner: juniper::FieldError<WundergraphScalarValue>,
24+
},
1925
}

wundergraph/src/filter/build_filter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use crate::diesel_ext::BoxableFilter;
12
use diesel::backend::Backend;
23
use diesel::expression::{Expression, NonAggregate, SqlLiteral};
34
use diesel::query_builder::QueryFragment;
45
use diesel::sql_types::Bool;
5-
use crate::diesel_ext::BoxableFilter;
66

77
/// A trait that indicates that some type could be converted into a sql filter
88
/// operation.
@@ -37,7 +37,7 @@ where
3737
type Ret = T::Ret;
3838

3939
fn into_filter(self) -> Option<Self::Ret> {
40-
self.and_then(|i| i.into_filter())
40+
self.and_then(BuildFilter::into_filter)
4141
}
4242
}
4343

wundergraph/src/filter/collector/and.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use super::FilterCollector;
22
use crate::filter::build_filter::BuildFilter;
33

4+
use crate::diesel_ext::BoxableFilter;
45
use diesel::backend::Backend;
56
use diesel::query_builder::QueryFragment;
67
use diesel::{AppearsOnTable, BoolExpressionMethods};
7-
use crate::diesel_ext::BoxableFilter;
88

99
use std::fmt::{self, Debug};
1010

wundergraph/src/filter/collector/or.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use super::FilterCollector;
22
use crate::filter::build_filter::BuildFilter;
33

4+
use crate::diesel_ext::BoxableFilter;
45
use diesel::backend::Backend;
56
use diesel::query_builder::QueryFragment;
67
use diesel::{AppearsOnTable, BoolExpressionMethods};
7-
use crate::diesel_ext::BoxableFilter;
88

99
use std::fmt::{self, Debug};
1010

wundergraph/src/filter/common_filter/eq.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ use std::marker::PhantomData;
33
use crate::filter::build_filter::BuildFilter;
44
use crate::scalar::WundergraphScalarValue;
55

6+
use crate::diesel_ext::BoxableFilter;
67
use diesel::backend::Backend;
78
use diesel::expression::{operators, AsExpression, Expression, NonAggregate};
89
use diesel::query_builder::QueryFragment;
910
use diesel::serialize::ToSql;
1011
use diesel::sql_types::{Bool, HasSqlType};
1112
use diesel::{AppearsOnTable, Column, ExpressionMethods};
12-
use crate::diesel_ext::BoxableFilter;
1313

1414
use juniper::{InputValue, ToInputValue};
1515

@@ -18,7 +18,7 @@ pub struct Eq<T, C>(Option<T>, PhantomData<C>);
1818

1919
impl<T, C> Eq<T, C> {
2020
pub(super) fn new(v: Option<T>) -> Self {
21-
Eq(v, PhantomData)
21+
Self(v, PhantomData)
2222
}
2323
}
2424

@@ -27,7 +27,7 @@ where
2727
T: Clone,
2828
{
2929
fn clone(&self) -> Self {
30-
Eq(self.0.clone(), PhantomData)
30+
Self(self.0.clone(), PhantomData)
3131
}
3232
}
3333

@@ -44,7 +44,7 @@ where
4444
type Ret = Box<dyn BoxableFilter<C::Table, DB, SqlType = Bool>>;
4545

4646
fn into_filter(self) -> Option<Self::Ret> {
47-
let Eq(filter, _) = self;
47+
let Self(filter, _) = self;
4848
filter.map(|v| Box::new(C::default().eq(v)) as Box<_>)
4949
}
5050
}

wundergraph/src/filter/common_filter/eq_any.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ use std::marker::PhantomData;
33
use crate::filter::build_filter::BuildFilter;
44
use crate::scalar::WundergraphScalarValue;
55

6+
use crate::diesel_ext::BoxableFilter;
67
use diesel::backend::Backend;
78
use diesel::expression::array_comparison::{In, Many};
89
use diesel::expression::{AsExpression, Expression, NonAggregate};
910
use diesel::query_builder::QueryFragment;
1011
use diesel::serialize::ToSql;
1112
use diesel::sql_types::{Bool, HasSqlType};
1213
use diesel::{AppearsOnTable, Column, ExpressionMethods};
13-
use crate::diesel_ext::BoxableFilter;
1414

1515
use juniper::{InputValue, ToInputValue};
1616

@@ -19,7 +19,7 @@ pub struct EqAny<T, C>(Option<Vec<T>>, PhantomData<C>);
1919

2020
impl<T, C> EqAny<T, C> {
2121
pub(super) fn new(v: Option<Vec<T>>) -> Self {
22-
EqAny(v, PhantomData)
22+
Self(v, PhantomData)
2323
}
2424
}
2525

@@ -28,7 +28,7 @@ where
2828
T: Clone,
2929
{
3030
fn clone(&self) -> Self {
31-
EqAny(self.0.clone(), PhantomData)
31+
Self(self.0.clone(), PhantomData)
3232
}
3333
}
3434

@@ -45,7 +45,7 @@ where
4545
type Ret = Box<dyn BoxableFilter<C::Table, DB, SqlType = Bool>>;
4646

4747
fn into_filter(self) -> Option<Self::Ret> {
48-
let EqAny(filter, _) = self;
48+
let Self(filter, _) = self;
4949
filter.map(|v| Box::new(C::default().eq_any(v)) as Box<_>)
5050
}
5151
}

wundergraph/src/filter/common_filter/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ use crate::filter::collector::{AndCollector, FilterCollector};
33
use crate::filter::filter_value::FilterValue;
44
use crate::filter::inner_filter::InnerFilter;
55

6+
use crate::diesel_ext::BoxableFilter;
67
use diesel::backend::Backend;
78
use diesel::expression::array_comparison::{In, Many};
89
use diesel::expression::{operators, AppearsOnTable, AsExpression, NonAggregate};
910
use diesel::query_builder::QueryFragment;
1011
use diesel::serialize::ToSql;
1112
use diesel::sql_types::{Bool, HasSqlType, SingleValue};
1213
use diesel::Column;
13-
use crate::diesel_ext::BoxableFilter;
1414

1515
use juniper::meta::{Argument, MetaType};
1616
use juniper::{FromInputValue, GraphQLType, InputValue, LookAheadValue, Registry, ToInputValue};
1717

1818
use crate::helper::{FromLookAheadValue, NameBuilder, Nameable};
19-
use indexmap::IndexMap;
2019
use crate::scalar::WundergraphScalarValue;
20+
use indexmap::IndexMap;
2121

2222
mod eq;
2323
mod eq_any;

wundergraph/src/filter/common_filter/not_eq.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ use std::marker::PhantomData;
33
use crate::filter::build_filter::BuildFilter;
44
use crate::scalar::WundergraphScalarValue;
55

6+
use crate::diesel_ext::BoxableFilter;
67
use diesel::backend::Backend;
78
use diesel::expression::{operators, AsExpression, Expression, NonAggregate};
89
use diesel::query_builder::QueryFragment;
910
use diesel::serialize::ToSql;
1011
use diesel::sql_types::{Bool, HasSqlType};
1112
use diesel::{AppearsOnTable, Column, ExpressionMethods};
12-
use crate::diesel_ext::BoxableFilter;
1313

1414
use juniper::{InputValue, ToInputValue};
1515

@@ -18,7 +18,7 @@ pub struct NotEq<T, C>(Option<T>, PhantomData<C>);
1818

1919
impl<T, C> NotEq<T, C> {
2020
pub(super) fn new(v: Option<T>) -> Self {
21-
NotEq(v, PhantomData)
21+
Self(v, PhantomData)
2222
}
2323
}
2424

@@ -27,7 +27,7 @@ where
2727
T: Clone,
2828
{
2929
fn clone(&self) -> Self {
30-
NotEq(self.0.clone(), PhantomData)
30+
Self(self.0.clone(), PhantomData)
3131
}
3232
}
3333

@@ -44,7 +44,7 @@ where
4444
type Ret = Box<dyn BoxableFilter<C::Table, DB, SqlType = Bool>>;
4545

4646
fn into_filter(self) -> Option<Self::Ret> {
47-
let NotEq(filter, _) = self;
47+
let Self(filter, _) = self;
4848
filter.map(|v| Box::new(C::default().ne(v)) as Box<_>)
4949
}
5050
}

0 commit comments

Comments
 (0)