-
Thanks for the effort put in this lib! I am new to rust and graphql, so maybe my assumptions etc. are wrong.
And someone could query it like:
This might be a bad example but the point is that the objects are linked between each other and the API consumer can access the fields on nested levels as well (which would not work if you e.g. use an user_id instead of the User object). In rust it is not allowed to build this cycle in a struct (I would like to use structs (with e.g. SimpleObject) for the graphql generation). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello! In fact we do not build a really recursive struct, it's more about functions. Here is an example. With something like this: struct Foo;
struct Bar;
#[Object]
impl Foo {
async fn bar(&self) -> Bar {
Bar
}
}
#[Object]
impl Bar {
async fn foo(&self) -> Foo {
Foo
}
async fn something(&self) -> bool {
true
}
}
#[Object]
impl Query {
async fn foo(&self) -> Foo {
Foo
}
}
struct Query; It would allow you to do query like this: query test4 {
foo {
bar {
foo {
bar {
foo {
bar {
something
}
}
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
Hello!
In fact we do not build a really recursive struct, it's more about functions. Here is an example.
With something like this:
It would allow you to do query like this: