-
Notifications
You must be signed in to change notification settings - Fork 429
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
Default to generic ScalarValue in #[graphql_object] macro #779
Conversation
f10bea0
to
86d768b
Compare
# Conflicts: # integration_tests/juniper_tests/src/custom_scalar.rs # juniper_graphql_ws/src/lib.rs
@LegNeato @ccbrown I've made it, but I'm unsure because of consequences it does. Please, review how examples were transformed. The main pain point goes from fallible fields, because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great work. I'm worried...it seems like this change bleeds into the developer experience heavily. Before, you basically had one place where you had to deal with scalar values (mixing the derive and the proc macro). Now, it shows up in a bunch of function signatures and turbofish calls by default.
With some trickery to avoid conflicting with the existing reflexive implementation, it may be possible to implement One of the weirdest things about this PR to me is that there's an increasing number of places where a type named DefaultScalarValue is no longer the default. That line in the quickstart that says "specify DefaultScalarValue if you don't want the default behavior" might be a bit of a head scratcher. Makes me wonder if a name like "StandardScalarValue" would be more appropriate. |
@ccbrown @LegNeato yeah... you've confirmed my worries 🙃
What a nice idea! Thank you! I'll try to poke with it more. |
@ccbrown yeah... it's very quickly hits into the specialization problem. But I've succeed to imitate the specialization in this situation with a Now I should re-refactor the changes in tests, examples, etc. |
# Conflicts: # integration_tests/juniper_tests/src/codegen/impl_scalar.rs
… into fix-generic-scalar-in-objects # Conflicts: # integration_tests/juniper_tests/src/custom_scalar.rs
@ccbrown @LegNeato please look, now it's much more convenient. Fallible fields and subscription coerce nicely. The only place left, where I cannot hide the type parameter is the GraphQL interface, when the trait object is used (enums are OK). Though it's very rare case, and I may poke with it later. |
… into fix-generic-scalar-in-objects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is definitely looking a lot nicer. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Prepare for making code generation usable from a build script Move code generation into its own module Re-enable the lints Move lots of stuff into code_gen module Flatten some modules Rename juniper-from-schema-code-gen to juniper-from-schema-proc-macro Move code generation stuff into juniper-from-schema-code-gen Clean up dependencies Add `juniper-from-schema-build` to compiling schema in "build.rs" Update build script Support juniper no longer defaulting to `DefaultScalarValue` for `#[graphql_object]` graphql-rust/juniper#779 Update changelog
Fixes #769
Fixes #580
This PR makes
#[graphql_object]
macro to generate code which is generic overS: ScalarValue
by default. Previously,DefaultScalarValue
has been used.Checklist
juniper
crate testsjuniper_codegen
crate tests