-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
#[derive(GraphQLInterface)]
to use structs as GraphQL int…
…erfaces (#1026) - support `#[graphql_interface]` on structs
- Loading branch information
Showing
125 changed files
with
6,537 additions
and
384 deletions.
There are no files selected for viewing
8 changes: 3 additions & 5 deletions
8
integration_tests/codegen_fail/fail/input-object/derive_incompatible_object.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
7 changes: 0 additions & 7 deletions
7
integration_tests/codegen_fail/fail/interface/additional_non_nullable_argument.stderr
This file was deleted.
Oops, something went wrong.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
integration_tests/codegen_fail/fail/interface/attr_wrong_item.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 interface #[graphql_interface] attribute is applicable to trait and struct definitions only | ||
--> fail/interface/attr_wrong_item.rs:9:1 | ||
| | ||
9 | enum Character {} | ||
| ^^^^^^^^^^^^^^^^^ |
12 changes: 12 additions & 0 deletions
12
integration_tests/codegen_fail/fail/interface/derive_wrong_item.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,12 @@ | ||
use juniper::{GraphQLInterface, GraphQLObject}; | ||
|
||
#[derive(GraphQLObject)] | ||
pub struct ObjA { | ||
test: String, | ||
} | ||
|
||
#[derive(GraphQLInterface)] | ||
#[graphql(for = ObjA)] | ||
enum Character {} | ||
|
||
fn main() {} |
6 changes: 6 additions & 0 deletions
6
integration_tests/codegen_fail/fail/interface/derive_wrong_item.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,6 @@ | ||
error: GraphQL interface can only be derived on structs | ||
--> fail/interface/derive_wrong_item.rs:9:1 | ||
| | ||
9 | / #[graphql(for = ObjA)] | ||
10 | | enum Character {} | ||
| |_________________^ |
7 changes: 0 additions & 7 deletions
7
integration_tests/codegen_fail/fail/interface/field_non_output_return_type.stderr
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
integration_tests/codegen_fail/fail/interface/missing_field.stderr
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
integration_tests/codegen_fail/fail/interface/missing_field_argument.stderr
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
integration_tests/codegen_fail/fail/interface/non_subtype_return.stderr
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
...gration_tests/codegen_fail/fail/interface/struct/attr_additional_non_nullable_argument.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,19 @@ | ||
use juniper::{graphql_interface, graphql_object}; | ||
|
||
pub struct ObjA { | ||
id: String, | ||
} | ||
|
||
#[graphql_object(impl = CharacterValue)] | ||
impl ObjA { | ||
fn id(&self, is_present: bool) -> &str { | ||
is_present.then(|| self.id.as_str()).unwrap_or("missing") | ||
} | ||
} | ||
|
||
#[graphql_interface(for = ObjA)] | ||
struct Character { | ||
id: String, | ||
} | ||
|
||
fn main() {} |
7 changes: 7 additions & 0 deletions
7
...ion_tests/codegen_fail/fail/interface/struct/attr_additional_non_nullable_argument.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,7 @@ | ||
error[E0080]: evaluation of constant value failed | ||
--> fail/interface/struct/attr_additional_non_nullable_argument.rs:16:5 | ||
| | ||
16 | id: String, | ||
| ^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: Field `id`: Argument `isPresent` of type `Boolean!` isn't present on the interface and so has to be nullable.', $DIR/fail/interface/struct/attr_additional_non_nullable_argument.rs:16:5 | ||
| | ||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) |
8 changes: 8 additions & 0 deletions
8
integration_tests/codegen_fail/fail/interface/struct/attr_field_double_underscored.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_interface; | ||
|
||
#[graphql_interface] | ||
struct Character { | ||
__id: String, | ||
} | ||
|
||
fn main() {} |
7 changes: 7 additions & 0 deletions
7
integration_tests/codegen_fail/fail/interface/struct/attr_field_double_underscored.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,7 @@ | ||
error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. | ||
--> fail/interface/struct/attr_field_double_underscored.rs:5:5 | ||
| | ||
5 | __id: String, | ||
| ^^^^ | ||
| | ||
= note: https://spec.graphql.org/June2018/#sec-Schema |
13 changes: 13 additions & 0 deletions
13
integration_tests/codegen_fail/fail/interface/struct/attr_field_non_output_return_type.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,13 @@ | ||
use juniper::{graphql_interface, GraphQLInputObject}; | ||
|
||
#[derive(GraphQLInputObject)] | ||
pub struct ObjB { | ||
id: i32, | ||
} | ||
|
||
#[graphql_interface] | ||
struct Character { | ||
id: ObjB, | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
...gration_tests/codegen_fail/fail/interface/struct/attr_field_non_output_return_type.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[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied | ||
--> fail/interface/struct/attr_field_non_output_return_type.rs:10:9 | ||
| | ||
10 | id: ObjB, | ||
| ^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` |
11 changes: 11 additions & 0 deletions
11
integration_tests/codegen_fail/fail/interface/struct/attr_fields_duplicate.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,11 @@ | ||
use juniper::graphql_interface; | ||
|
||
#[graphql_interface] | ||
struct Character { | ||
id: String, | ||
|
||
#[graphql(name = "id")] | ||
id2: String, | ||
} | ||
|
||
fn main() {} |
12 changes: 12 additions & 0 deletions
12
integration_tests/codegen_fail/fail/interface/struct/attr_fields_duplicate.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,12 @@ | ||
error: GraphQL interface must have a different name for each field | ||
--> fail/interface/struct/attr_fields_duplicate.rs:4:1 | ||
| | ||
4 | / struct Character { | ||
5 | | id: String, | ||
6 | | | ||
7 | | #[graphql(name = "id")] | ||
8 | | id2: String, | ||
9 | | } | ||
| |_^ | ||
| | ||
= note: https://spec.graphql.org/June2018/#sec-Interfaces |
14 changes: 14 additions & 0 deletions
14
integration_tests/codegen_fail/fail/interface/struct/attr_implementers_duplicate_pretty.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_interface, GraphQLObject}; | ||
|
||
#[derive(GraphQLObject)] | ||
#[graphql(impl = CharacterValue)] | ||
pub struct ObjA { | ||
id: String, | ||
} | ||
|
||
#[graphql_interface(for = [ObjA, ObjA])] | ||
struct Character { | ||
id: String, | ||
} | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
...ration_tests/codegen_fail/fail/interface/struct/attr_implementers_duplicate_pretty.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,11 @@ | ||
error: duplicated attribute argument found | ||
--> fail/interface/struct/attr_implementers_duplicate_pretty.rs:9:34 | ||
| | ||
9 | #[graphql_interface(for = [ObjA, ObjA])] | ||
| ^^^^ | ||
|
||
error[E0412]: cannot find type `CharacterValue` in this scope | ||
--> fail/interface/struct/attr_implementers_duplicate_pretty.rs:4:18 | ||
| | ||
4 | #[graphql(impl = CharacterValue)] | ||
| ^^^^^^^^^^^^^^ not found in this scope |
16 changes: 16 additions & 0 deletions
16
integration_tests/codegen_fail/fail/interface/struct/attr_implementers_duplicate_ugly.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_interface, GraphQLObject}; | ||
|
||
#[derive(GraphQLObject)] | ||
#[graphql(impl = CharacterValue)] | ||
pub struct ObjA { | ||
id: String, | ||
} | ||
|
||
type ObjAlias = ObjA; | ||
|
||
#[graphql_interface(for = [ObjA, ObjAlias])] | ||
struct Character { | ||
id: String, | ||
} | ||
|
||
fn main() {} |
21 changes: 21 additions & 0 deletions
21
integration_tests/codegen_fail/fail/interface/struct/attr_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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error[E0119]: conflicting implementations of trait `std::convert::From<ObjA>` for type `CharacterValueEnum<ObjA, ObjA>` | ||
--> fail/interface/struct/attr_implementers_duplicate_ugly.rs:11:1 | ||
| | ||
11 | #[graphql_interface(for = [ObjA, ObjAlias])] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| first implementation here | ||
| conflicting implementation for `CharacterValueEnum<ObjA, ObjA>` | ||
| | ||
= 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 `<CharacterValueEnum<ObjA, ObjA> as juniper::GraphQLInterface<__S>>::mark::_::{closure#0}::MutuallyExclusive` for type `ObjA` | ||
--> fail/interface/struct/attr_implementers_duplicate_ugly.rs:11:1 | ||
| | ||
11 | #[graphql_interface(for = [ObjA, ObjAlias])] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| first implementation here | ||
| conflicting implementation for `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) |
14 changes: 14 additions & 0 deletions
14
integration_tests/codegen_fail/fail/interface/struct/attr_missing_field.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_interface, GraphQLObject}; | ||
|
||
#[derive(GraphQLObject)] | ||
#[graphql(impl = CharacterValue)] | ||
pub struct ObjA { | ||
test: String, | ||
} | ||
|
||
#[graphql_interface(for = ObjA)] | ||
struct Character { | ||
id: String, | ||
} | ||
|
||
fn main() {} |
7 changes: 7 additions & 0 deletions
7
integration_tests/codegen_fail/fail/interface/struct/attr_missing_field.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,7 @@ | ||
error[E0080]: evaluation of constant value failed | ||
--> fail/interface/struct/attr_missing_field.rs:11:5 | ||
| | ||
11 | id: String, | ||
| ^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: Field `id` isn't implemented on `ObjA`.', $DIR/fail/interface/struct/attr_missing_field.rs:11:5 | ||
| | ||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) |
14 changes: 14 additions & 0 deletions
14
integration_tests/codegen_fail/fail/interface/struct/attr_missing_for_attr.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_interface, GraphQLObject}; | ||
|
||
#[derive(GraphQLObject)] | ||
#[graphql(impl = CharacterValue)] | ||
pub struct ObjA { | ||
id: String, | ||
} | ||
|
||
#[graphql_interface] | ||
struct Character { | ||
id: String, | ||
} | ||
|
||
fn main() {} |
7 changes: 7 additions & 0 deletions
7
integration_tests/codegen_fail/fail/interface/struct/attr_missing_for_attr.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,7 @@ | ||
error[E0080]: evaluation of constant value failed | ||
--> fail/interface/struct/attr_missing_for_attr.rs:3:10 | ||
| | ||
3 | #[derive(GraphQLObject)] | ||
| ^^^^^^^^^^^^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: missing implementer reference in interface's `for` attribute.', $DIR/fail/interface/struct/attr_missing_for_attr.rs:3:10 | ||
| | ||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) |
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
7 changes: 7 additions & 0 deletions
7
integration_tests/codegen_fail/fail/interface/struct/attr_missing_impl_attr.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,7 @@ | ||
error[E0080]: evaluation of constant value failed | ||
--> fail/interface/struct/attr_missing_impl_attr.rs:8:1 | ||
| | ||
8 | #[graphql_interface(for = ObjA)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: missing interface reference in implementer's `impl` attribute.', $DIR/fail/interface/struct/attr_missing_impl_attr.rs:8:1 | ||
| | ||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) |
8 changes: 8 additions & 0 deletions
8
integration_tests/codegen_fail/fail/interface/struct/attr_name_double_underscored.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_interface; | ||
|
||
#[graphql_interface] | ||
struct __Character { | ||
id: String, | ||
} | ||
|
||
fn main() {} |
7 changes: 7 additions & 0 deletions
7
integration_tests/codegen_fail/fail/interface/struct/attr_name_double_underscored.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,7 @@ | ||
error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. | ||
--> fail/interface/struct/attr_name_double_underscored.rs:4:8 | ||
| | ||
4 | struct __Character { | ||
| ^^^^^^^^^^^ | ||
| | ||
= note: https://spec.graphql.org/June2018/#sec-Schema |
6 changes: 6 additions & 0 deletions
6
integration_tests/codegen_fail/fail/interface/struct/attr_no_fields.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,6 @@ | ||
use juniper::graphql_interface; | ||
|
||
#[graphql_interface] | ||
struct Character {} | ||
|
||
fn main() {} |
7 changes: 7 additions & 0 deletions
7
integration_tests/codegen_fail/fail/interface/struct/attr_no_fields.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,7 @@ | ||
error: GraphQL interface must have at least one field | ||
--> fail/interface/struct/attr_no_fields.rs:4:1 | ||
| | ||
4 | struct Character {} | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: https://spec.graphql.org/June2018/#sec-Interfaces |
14 changes: 14 additions & 0 deletions
14
integration_tests/codegen_fail/fail/interface/struct/attr_non_subtype_return.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_interface, GraphQLObject}; | ||
|
||
#[derive(GraphQLObject)] | ||
#[graphql(impl = CharacterValue)] | ||
pub struct ObjA { | ||
id: Vec<String>, | ||
} | ||
|
||
#[graphql_interface(for = ObjA)] | ||
struct Character { | ||
id: String, | ||
} | ||
|
||
fn main() {} |
7 changes: 7 additions & 0 deletions
7
integration_tests/codegen_fail/fail/interface/struct/attr_non_subtype_return.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,7 @@ | ||
error[E0080]: evaluation of constant value failed | ||
--> fail/interface/struct/attr_non_subtype_return.rs:11:5 | ||
| | ||
11 | id: String, | ||
| ^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: Field `id`: implementor is expected to return a subtype of interface's return object: `[String!]!` is not a subtype of `String!`.', $DIR/fail/interface/struct/attr_non_subtype_return.rs:11:5 | ||
| | ||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) |
6 changes: 6 additions & 0 deletions
6
integration_tests/codegen_fail/fail/interface/struct/attr_unnamed_field.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,6 @@ | ||
use juniper::graphql_interface; | ||
|
||
#[graphql_interface] | ||
struct Character(i32); | ||
|
||
fn main() {} |
7 changes: 7 additions & 0 deletions
7
integration_tests/codegen_fail/fail/interface/struct/attr_unnamed_field.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,7 @@ | ||
error: GraphQL interface expected named struct field | ||
--> fail/interface/struct/attr_unnamed_field.rs:4:18 | ||
| | ||
4 | struct Character(i32); | ||
| ^^^ | ||
| | ||
= note: https://spec.graphql.org/June2018/#sec-Interfaces |
20 changes: 20 additions & 0 deletions
20
...ation_tests/codegen_fail/fail/interface/struct/derive_additional_non_nullable_argument.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,20 @@ | ||
use juniper::{graphql_object, GraphQLInterface}; | ||
|
||
pub struct ObjA { | ||
id: String, | ||
} | ||
|
||
#[graphql_object(impl = CharacterValue)] | ||
impl ObjA { | ||
fn id(&self, is_present: bool) -> &str { | ||
is_present.then(|| self.id.as_str()).unwrap_or("missing") | ||
} | ||
} | ||
|
||
#[derive(GraphQLInterface)] | ||
#[graphql(for = ObjA)] | ||
struct Character { | ||
id: String, | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.