-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- support generic scalars - make it applicable to type aliases and struct/enums/unions
- Loading branch information
Showing
47 changed files
with
4,297 additions
and
2,041 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
12 changes: 6 additions & 6 deletions
12
integration_tests/codegen_fail/fail/interface/implementers_duplicate_ugly.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
error[E0119]: conflicting implementations of trait `<CharacterValueEnum<ObjA, ObjA> as juniper::GraphQLInterface<__S>>::mark::_::{closure#0}::MutuallyExclusive` for type `ObjA` | ||
error[E0119]: conflicting implementations of trait `std::convert::From<ObjA>` for type `CharacterValueEnum<ObjA, ObjA>` | ||
--> fail/interface/implementers_duplicate_ugly.rs:11:1 | ||
| | ||
11 | #[graphql_interface(for = [ObjA, ObjAlias])] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| first implementation here | ||
| conflicting implementation for `ObjA` | ||
| conflicting implementation for `CharacterValueEnum<ObjA, ObjA>` | ||
| | ||
= note: this error originates in the macro `::juniper::sa::assert_type_ne_all` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
= note: this error originates in the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0119]: conflicting implementations of trait `std::convert::From<ObjA>` for type `CharacterValueEnum<ObjA, ObjA>` | ||
error[E0119]: conflicting implementations of trait `<CharacterValueEnum<ObjA, ObjA> as juniper::GraphQLInterface<__S>>::mark::_::{closure#0}::MutuallyExclusive` for type `ObjA` | ||
--> fail/interface/implementers_duplicate_ugly.rs:11:1 | ||
| | ||
11 | #[graphql_interface(for = [ObjA, ObjAlias])] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| first implementation here | ||
| conflicting implementation for `CharacterValueEnum<ObjA, ObjA>` | ||
| conflicting implementation for `ObjA` | ||
| | ||
= note: this error originates in the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
= note: this error originates in the macro `::juniper::sa::assert_type_ne_all` (in Nightly builds, run with -Z macro-backtrace for more info) |
16 changes: 16 additions & 0 deletions
16
integration_tests/codegen_fail/fail/scalar/derive_input/impl_invalid_url.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use juniper::{graphql_scalar, InputValue, ScalarValue, Value}; | ||
|
||
#[graphql_scalar(specified_by_url = "not an url", parse_token(i32))] | ||
struct ScalarSpecifiedByUrl(i32); | ||
|
||
impl ScalarSpecifiedByUrl { | ||
fn to_output<S: ScalarValue>(&self) -> Value<S> { | ||
Value::scalar(0) | ||
} | ||
|
||
fn from_input<S: ScalarValue>(_: &InputValue<S>) -> Result<Self, String> { | ||
Ok(Self) | ||
} | ||
} | ||
|
||
fn main() {} |
17 changes: 17 additions & 0 deletions
17
integration_tests/codegen_fail/fail/scalar/derive_input/impl_invalid_url.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error: Invalid URL: relative URL without a base | ||
--> fail/scalar/derive_input/impl_invalid_url.rs:3:37 | ||
| | ||
3 | #[graphql_scalar(specified_by_url = "not an url", parse_token(i32))] | ||
| ^^^^^^^^^^^^ | ||
|
||
error[E0412]: cannot find type `ScalarSpecifiedByUrl` in this scope | ||
--> fail/scalar/derive_input/impl_invalid_url.rs:6:6 | ||
| | ||
6 | impl ScalarSpecifiedByUrl { | ||
| ^^^^^^^^^^^^^^^^^^^^ not found in this scope | ||
|
||
error: the `Self` constructor can only be used with tuple or unit structs | ||
--> fail/scalar/derive_input/impl_invalid_url.rs:12:12 | ||
| | ||
12 | Ok(Self) | ||
| ^^^^ |
7 changes: 0 additions & 7 deletions
7
integration_tests/codegen_fail/fail/scalar/derive_invalid_url.rs
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
integration_tests/codegen_fail/fail/scalar/derive_invalid_url.stderr
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
integration_tests/codegen_fail/fail/scalar/impl_invalid_url.rs
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
integration_tests/codegen_fail/fail/scalar/impl_invalid_url.stderr
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
integration_tests/codegen_fail/fail/scalar/type_alias/impl_invalid_url.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use juniper::{graphql_scalar, InputValue, ScalarValue, Value}; | ||
|
||
struct ScalarSpecifiedByUrl; | ||
|
||
#[graphql_scalar( | ||
specified_by_url = "not an url", | ||
with = scalar, | ||
parse_token(i32), | ||
)] | ||
type Scalar = ScalarSpecifiedByUrl; | ||
|
||
mod scalar { | ||
use super::*; | ||
|
||
pub(super) fn to_output<S: ScalarValue>(_: &ScalarSpecifiedByUrl) -> Value<S> { | ||
Value::scalar(0) | ||
} | ||
|
||
pub(super) fn from_input<S: ScalarValue>( | ||
_: &InputValue<S>, | ||
) -> Result<ScalarSpecifiedByUrl, String> { | ||
Ok(ScalarSpecifiedByUrl) | ||
} | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
integration_tests/codegen_fail/fail/scalar/type_alias/impl_invalid_url.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: Invalid URL: relative URL without a base | ||
--> fail/scalar/type_alias/impl_invalid_url.rs:6:24 | ||
| | ||
6 | specified_by_url = "not an url", | ||
| ^^^^^^^^^^^^ |
14 changes: 14 additions & 0 deletions
14
integration_tests/codegen_fail/fail/scalar/type_alias/impl_with_not_all_resolvers.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use juniper::{graphql_scalar, Value}; | ||
|
||
struct Scalar; | ||
|
||
#[graphql_scalar(to_output_with = Scalar::to_output)] | ||
type CustomScalar = Scalar; | ||
|
||
impl Scalar { | ||
fn to_output(&self) -> Value { | ||
Value::scalar(0) | ||
} | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
integration_tests/codegen_fail/fail/scalar/type_alias/impl_with_not_all_resolvers.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: GraphQL scalar all custom resolvers have to be provided via `with` or combination of `to_output_with`, `from_input_with`, `parse_token_with` attributes | ||
--> fail/scalar/type_alias/impl_with_not_all_resolvers.rs:6:1 | ||
| | ||
6 | type CustomScalar = Scalar; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
8 changes: 8 additions & 0 deletions
8
integration_tests/codegen_fail/fail/scalar/type_alias/impl_without_resolvers.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use juniper::graphql_scalar; | ||
|
||
struct Scalar; | ||
|
||
#[graphql_scalar] | ||
type CustomScalar = Scalar; | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
integration_tests/codegen_fail/fail/scalar/type_alias/impl_without_resolvers.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: GraphQL scalar all custom resolvers have to be provided via `with` or combination of `to_output_with`, `from_input_with`, `parse_token_with` attributes | ||
--> fail/scalar/type_alias/impl_without_resolvers.rs:6:1 | ||
| | ||
6 | type CustomScalar = Scalar; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 0 additions & 125 deletions
125
integration_tests/juniper_tests/src/codegen/derive_scalar.rs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.