@@ -53,7 +53,9 @@ private DirectivesSchema(
53
53
54
54
// TODO:mess of exceptions
55
55
public static DirectivesSchema build (
56
- List <RestrictTypeFactory <?>> globalDirectives , Set <Class <?>> directiveTypes , Set <Class <?>> jakartaDirectiveTypes
56
+ List <RestrictTypeFactory <?>> globalDirectives ,
57
+ Set <Class <?>> directiveTypes ,
58
+ Set <Class <?>> jakartaDirectiveTypes
57
59
) throws ReflectiveOperationException {
58
60
Map <Class <? extends Annotation >, DirectiveCaller <?>> targets = new HashMap <>();
59
61
@@ -104,28 +106,27 @@ private DataFetcher<?> wrap(RestrictTypeFactory<?> directive, DataFetcher<?> fet
104
106
// TODO: hate having this cache here would love to scope against the env object but nothing to hook into dataload caused global leak
105
107
Map <DataFetchingEnvironment , CompletableFuture <RestrictType >> cache = Collections .synchronizedMap (new WeakHashMap <>());
106
108
107
- return env ->
108
- cache
109
- .computeIfAbsent (env , key -> directive .create (key ).thenApply (t -> t ))
110
- .thenCompose (restrict -> {
111
- try {
112
- Object response = fetcher .get (env );
113
- if (response instanceof CompletionStage ) {
114
- return ((CompletionStage ) response ).thenCompose (r -> applyRestrict (restrict , r ));
115
- }
116
- return applyRestrict (restrict , response );
117
- } catch (Exception e ) {
118
- if (e instanceof RuntimeException runtimeException ) {
119
- throw runtimeException ;
120
- }
121
- throw new RuntimeException (e );
109
+ return env -> cache
110
+ .computeIfAbsent (env , key -> directive .create (key ).thenApply (t -> t ))
111
+ .thenCompose (restrict -> {
112
+ try {
113
+ Object response = fetcher .get (env );
114
+ if (response instanceof CompletionStage ) {
115
+ return ((CompletionStage ) response ).thenCompose (r -> applyRestrict (restrict , r ));
122
116
}
123
- });
117
+ return applyRestrict (restrict , response );
118
+ } catch (Exception e ) {
119
+ if (e instanceof RuntimeException runtimeException ) {
120
+ throw runtimeException ;
121
+ }
122
+ throw new RuntimeException (e );
123
+ }
124
+ });
124
125
}
125
126
126
127
public boolean target (Method method , TypeMeta meta ) {
127
128
for (var globalRestricts : this .global ) {
128
- //TODO: extract class
129
+ // TODO: extract class
129
130
if (globalRestricts .extractType ().isAssignableFrom (meta .getType ())) {
130
131
return true ;
131
132
}
0 commit comments