-
Notifications
You must be signed in to change notification settings - Fork 434
Add a basic lookahead functionality #136
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
Conversation
Hi, Was looking at your implementation and had a few questions:
Many thanks for the contribution! |
As far as I understand the documentation of
I'm really bad in naming things, so just suggest a better name and I will change it
I have same code using this api, that provides a somehow working solution for a specific database. It is currently quite hacky, so I need to do some cleanup before showing it somewhere. |
@weiznich all great points. thnxs! Looking forward to your updates... : ) |
Just a little update about that: I've not forgotten about this PR, but I found that writing diesel code that interacts with the lookahead functionality involves quite a lot of boilerplate code. So I've decided to try to write some generic code that is able to be used in place of the boilerplate code, but this needs some time. |
This would be great! Thnxs!! |
So finally I got something to show. Please note that the look ahead functionality is not visible in the example code, because it is only used inside the library. |
@weiznich this is great! just downloaded your code and tried it. Seems to be working right out-of-the-box. Have not had much time to look into the details; however, I did notice the SQL queries pull all the fields on the first select, but not on the subsequent ones. Not sure if by design or oversight. I'll try to spend more time on it in the next week or so when I get a chance. Great stuff, btw!! |
@weiznich just wondering if it would be useful to use a proper pluralizer/inflector (e.g. https://github.com/whatisinternet/Inflector) for models when running them through the mutation macros for example. |
@fungl164 Thanks your suggestions.
I'm not sure if that's possible because I need the names currently as string literals. A maybe better solution would be to provide a way to pass custom names in there instead.
What do you exactly mean here? I will try to do a rebase in the next days so we could work on actively merging this. |
If you look at the GraphQL query (below), there is no request for 'hair_color'. However, when looking at the logs (also below), the first SELECT statement includes it as SQL field (even though it was not requested in GraphQL). Interestingly enough, the subsequent SELECT statements in the logs include only the exact fields as requested on the GraphQL query. So, I was just wondering why the first SELECT did not behave the same way (e.g. exact field extraction/selection in SQL as those submitted via the GraphQL query). Hope this makes sense... In any case, it all works fine in the end so thanks for the wonderful work you've put in. I just didn't know if this was the intended behavior, an optimization or a just a plain oversight in the implementation... |
This is totally expected. The current strategy is to load all fields of the table and then let juniper do the selection stuff. Only fields that represents other tables are handled different, because I think loading them would be become quite expensive. (As soon as I have landed all those PR's (this one and 2 or 3 to diesel) required to make wundergraph working I need to write some blog post about this 😉) @theduke @mhallin |
Codecov Report
@@ Coverage Diff @@
## master #136 +/- ##
==========================================
- Coverage 90.59% 90.41% -0.19%
==========================================
Files 95 96 +1
Lines 18083 18616 +533
==========================================
+ Hits 16383 16832 +449
- Misses 1700 1784 +84
Continue to review full report at Codecov.
|
I've tried a bit around how to implement a look ahead feature as described in #124.
This should be seen as WIP. I've only opened this PR to start some discussion about this design.