-
Notifications
You must be signed in to change notification settings - Fork 55
feat: add support for per request schema transformation and instrumentation #163
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
Codecov Report
@@ Coverage Diff @@
## master #163 +/- ##
===========================================
+ Coverage 68.11% 68.32% +0.2%
- Complexity 498 505 +7
===========================================
Files 33 35 +2
Lines 2578 2595 +17
Branches 431 431
===========================================
+ Hits 1756 1773 +17
Misses 644 644
Partials 178 178
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #163 +/- ##
============================================
- Coverage 70.67% 70.66% -0.02%
- Complexity 934 942 +8
============================================
Files 62 65 +3
Lines 4351 4421 +70
Branches 661 661
============================================
+ Hits 3075 3124 +49
- Misses 998 1019 +21
Partials 278 278
Continue to review full report at Codecov.
|
|
@molexx This is the PR to provide per request schema transformation to be able to apply field visibility function based on user profile in the execution context injection for query security. I will try implement security example using schema directives. Let me know what you think. |
a601390 to
ff0559c
Compare
ff0559c to
e089299
Compare
129a9e7 to
9fb44de
Compare
c0a7287 to
7146699
Compare
|
Thanks @igdianov , sorry I haven't had time to play with this until this week. Are your comments in the first post still valid after your later changes? graphql-java doesn't mention GraphqlFieldVisibility until v12 - although the class is in v11 maybe it isn't used until v12? If you think it should work then maybe my |
|
@molexx Thanks for feedback. I have not tried this yet and I don't know if |
7146699 to
d963dd6
Compare
4b007f1 to
1329528
Compare
642b84f to
f2ca2ea
Compare
f2ca2ea to
de717a7
Compare
|
@molexx I had a break to work on this today. I have refactored the implementation to apply Spring Boot auto-configuration support for @Bean
@RequestScope
public Supplier<GraphQLContext> graphqlContext(HttpServletRequest request, @AuthenticationPrincipal UserDetails user) {
return () -> GraphQLContext.newContext()
.of("request", request)
.of("user", user)
.build();
}I will need to add more tests and then merge it to master. Feel free to check it out and add your test cases. |
|
Ah looks great, thanks! I'll try it out. |
Hi, any plans to merge this? We use this on a branch and it works well. It would be great if we could go back to master! |
541a41f to
6c1d9a2
Compare
|
@duiscairt-foobar @molexx It is merged. Feel free to open a PR if need to fix something. :) |
|
Ah great thanks! |
|
Thanks 😀 |
This PR adds support for per request schema transformation and instrumentation the uses
GraphQLExecutorContextFactoryinterface:in order to create instance of
GraphQLExecutorContextinterface implemenation that will apply customizations to GraphQL schema field visibility, execution context, and instrumentation before executing query via:And then in QraphQLExecutor.execute(..)
There is Spring Boot auto-configuration support for
GraphQLContext,GraphqlFieldVisibilityandInstrumentationvia Java'sSupplierfunctional interface, to make it possible use@RequestScopemagic to inject Supplier functions per request, session, application, i.e.TODOs
Fixes #160
Fixes #89
Fixes #197