-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add impl derive for graphql objects #181
Conversation
Love it. Exactly what I wanted to add. Sadly, this will have to wait until proc macros hit stable. |
I will do a more thorough review soon, but some short hints:
It would be nice to specify the context also inside the regular code. #[graphql_object]
impl GraphQLObject for MyType<Context=SomeType> {
} |
proc-macro-hack is for function like macros? and sure that would be something to think about |
welp, I just upgraded this to the latest |
well the test was broken before because you pass |
Should I also add #[graphql_object]
impl GraphQLObject for MyType<Context=SomeType, Interfaces=(SomeInterface, AnotherInterface)> {
} (tuples being the only way to have multiple items with valid syntax) |
@theduke ? |
Does proc_macro being stabilized change this? Of course, it will still have to be gated because we don't want to bump our rust requirement that high yet so maybe not... |
I think it is not good to specify the context type as a bounds of associated types. I thinks it is prefer to be written as follows: #[graphql]
impl MyType {
type Context = ();
...
} In order to avoid confusion, we should clarify the specification of the attribute-style macro to be created... |
Good idea |
@ForsakenHarmony are you motivated to finishing this up? |
If you tell me what exactly you want |
A few things left to do:
I can absolutely help out with any of those, you just say if and what you are able to tackle. ( it's great that you started this in the first place!) === #[graphql_object]
impl GraphQLObject for MyType {
type Context = MyCtx;
...
} |
I'll take a look |
|
Codecov Report
@@ Coverage Diff @@
## master #181 +/- ##
==========================================
- Coverage 87.61% 86.86% -0.75%
==========================================
Files 101 102 +1
Lines 14415 14539 +124
==========================================
Hits 12629 12629
- Misses 1786 1910 +124
Continue to review full report at Codecov.
|
fc5815a
to
4c54425
Compare
Does this allow graohql queries/mutation to be split across multiple files? |
Nope |
@ForsakenHarmony what was contained in your recent push, and what's still TODO? |
it was just a rebase, pretty much everything, because you didn't respond before |
Yeah I can somewhat agree with this, I'm fine with the current solution. Also, I'd love to get this finished since I really want to use it myself. ^^ Just tell me what you want to tackle and I can do the rest. |
Mhm, yeah, I'm afraid we won't be able to solve that in a reasonable fashion. It would not be a problem for RLS based IDEs because they only handle the expanded code, I think for now we have to live with it. In the future we could provide a regular proc macro that replaces the current |
Ah, I just noticed something else due to the above issue: It would be quite confusing to have both a We should find a name that distinguishes the two clearly. Since with edition 2018 macros are not global and can be imported, my preference would be: #[juniper::impl_object]
impl Query{
...
} Anyone have other thoughts here? We could rename it to just |
what's the I'll probably do that and the |
The GraphQLType has a generic argument for the scalar type now. We should support setting this, I'd reckon with |
Since the scalar type is defined as an argument (not an associated type), it should be able to write as follows: #[juniper::impl_object]
impl<S> GraphQLType<S> for Query
where
S: juniper::ScalarValue + MyCustomBound,
{
...
} |
well, it might be better if you just implement it, don't have too much time and am not entirely sure what the best way is |
Continued in #333 due to Github being buggy. |
seems like you accidentally force pushed master or smth, making this empty did that once as well |
Wasn't an accident, I squashed your commits together. Jedenfalls nochmal danke. ;) |
https://gist.github.com/ForsakenHarmony/8d42d4963dec52d80853e48ff7401ef1#file-proc_macro-rs