Trying to figure out how to use new object macro when its subject gets derived as a part of another struct:
struct Person {
name: String,
}
#[juniper::object]
impl Person {
fn name(&self) -> &str {
self.name.as_str()
}
}
#[derive(GraphQLObject)]
struct Derived {
person: Person,
}
Error is on the line #[derive(GraphQLObject)]:
the trait bound `user::Person: juniper::GraphQLType<__S>` is not satisfied
the trait `juniper::GraphQLType<__S>` is not implemented for `user::Person`
help: consider adding a `where user::Person: juniper::GraphQLType<__S>` bound
This is an unfortunate interaction of generics.
I'm working on a fix, but for now you can do this:
#[derive(GraphQLObject)]
#[graphql(Scalar = juniper::DefaultScalarValue)]
struct Derived {
person: Person,
}
It works, thanks!
Most helpful comment
This is an unfortunate interaction of generics.
I'm working on a fix, but for now you can do this: