-
Notifications
You must be signed in to change notification settings - Fork 423
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
Any way to auto-generate struct field resolvers, and also hand-write a custom one? #377
Comments
I don't believe there is. Happy to review a PR! |
This is much wanted and there are multiple paths to this. One option, merging definitions, is discussed in #182 . My personally preferred way forward would be to apply a proc macro to a whole module to make this easy. This is currently only possible on nightly with the I'd want us to have code like this and make it just work: #[juniper::module]
mod graphql {
#[derive(GraphQLObject)]
struct MyType {
}
#[juniper::object]
impl MyType {
fn extra_resolver() -> bool { true }
....
}
} |
Hi Christian,
That's great to hear there is interest in this. At the moment my macro
writing skills are not up to the task, but if that changes, I'll try to do
it. Incidentally, I did also try to write another unrelated macro, but
noticed that it doesn't work when called from within the graphql_object!()
call.
Cheers,
Henry
…On Mon, Jun 24, 2019 at 7:38 PM Christian Legnitto ***@***.***> wrote:
I don't believe there is. Happy to review a PR!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#377?email_source=notifications&email_token=ABI3OFWVJM3IAKV7RFFPCGLP4GAI3A5CNFSM4H2K3QJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYOZNJY#issuecomment-505255591>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABI3OFUKRLQ3H6DG6HU65Z3P4GAI3ANCNFSM4H2K3QJQ>
.
|
@theduke I like the module idea. Can we leverage the new(ish) "extends" keyword here? |
Let's track this in #182 . |
Is there a way to have all fields of a struct have auto-generated resolvers, as provided by #[derive(GraphQLObject)], but be able to custom-derive a few more, as can be done with graphql_object! macro?
Since the two techniques don't mix, it seems the only choice is to use graphql_object! macro, and hand-write all of the trivial resolvers along with the custom ones.
The text was updated successfully, but these errors were encountered: