-
Notifications
You must be signed in to change notification settings - Fork 433
GraphQLType is not satisfied with juniper::object #467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are you able to share a minimal reproduction script? It’s a bit hard to say what’s wrong from what you posted. |
I have found similar issue. Here is minimal example which fails to build. |
Bump, any ideas? |
Hello, Any updates on this ?
I also trying to use it as in @andy128k example |
Hello, I found a workaround, so it will compile and work as expected. The idea is that you don't use So instead of: pub struct Article {
pub title: String,
}
#[juniper::object(name = "Article")]
impl Article {
fn title(&self) -> &str { &self.title }
}
#[derive(juniper::GraphQLObject)]
pub struct Blog {
pub url: String,
pub description: Vec<String>,
pub articles: Vec<Article>,
} You define: pub struct Article {
pub title: String,
}
#[juniper::object(name = "Article")]
impl Article {
fn title(&self) -> &str { &self.title }
}
pub struct Blog {
pub url: String,
pub description: Vec<String>,
pub articles: Vec<Article>,
}
#[juniper::object(name = "Blog")]
impl Blog {
// ...
} |
@andy128k @RyuuGan Have you tried adding the #[derive(juniper::GraphQLObject)]
#[graphql(scalar = juniper::DefaultScalarValue)]
pub struct Blog {
pub url: String,
pub description: Vec<String>,
pub articles: Vec<Article>,
} For some reason it is required, otherwise generic will be used instead of the juniper/juniper_codegen/src/util.rs Lines 734 to 740 in eddf948
since
Not sure if this is a bug or by design. 🤔 |
I'm running into this issue as well when trying to use pub struct MyObject {
id: i32,
}
#[juniper::object]
impl MyObject {
fn id(&self) -> i32 {
&self.id
}
}
enum MyUnion {
MyObject(MyObject),
}
juniper::graphql_union!(MyUnion: () where Scalar = <S> |&self| {
instance_resolvers: |_| {
&MyObject => match *self { MyUnion::MyObject(ref h) => Some(h), _ => None },
}
}); This results with
|
@urkle I guess that's because Try this:
Also, |
@tyranron Awesome Thanks! That fixed the issue. |
Currently using 0.14.1. I'm attempting to implement fields with the juniper::object macro.
On compilation, i see the following error:
error[E0277]: the trait bound
models::Event: juniper::GraphQLType<__S>
is not satisfiedOn this struct, I've implemented another trait that does not have the juniper::object macro.
impl TraitName for Event
I've looked through the docs and issues and have been unable to find a solution.
Thanks!
The text was updated successfully, but these errors were encountered: