Skip to content

Commit aa7ce9e

Browse files
committed
formatter
1 parent 0f0b741 commit aa7ce9e

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

graphql-builder/src/main/java/com/phocassoftware/graphql/builder/DirectivesSchema.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ private DirectivesSchema(
5353

5454
// TODO:mess of exceptions
5555
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
5759
) throws ReflectiveOperationException {
5860
Map<Class<? extends Annotation>, DirectiveCaller<?>> targets = new HashMap<>();
5961

@@ -104,28 +106,27 @@ private DataFetcher<?> wrap(RestrictTypeFactory<?> directive, DataFetcher<?> fet
104106
// TODO: hate having this cache here would love to scope against the env object but nothing to hook into dataload caused global leak
105107
Map<DataFetchingEnvironment, CompletableFuture<RestrictType>> cache = Collections.synchronizedMap(new WeakHashMap<>());
106108

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));
122116
}
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+
});
124125
}
125126

126127
public boolean target(Method method, TypeMeta meta) {
127128
for (var globalRestricts : this.global) {
128-
//TODO: extract class
129+
// TODO: extract class
129130
if (globalRestricts.extractType().isAssignableFrom(meta.getType())) {
130131
return true;
131132
}

graphql-builder/src/main/java/com/phocassoftware/graphql/builder/SchemaBuilder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ private static DirectivesSchema getDirectivesSchema(Reflections reflections) thr
182182

183183
private static Set<Class<?>> getJakartaAnnotations() {
184184
Reflections reflections = new Reflections("jakarta.validation.constraints", SubTypes.filterResultsBy(c -> true));
185-
return reflections.getSubTypesOf(Object.class).stream()
185+
return reflections
186+
.getSubTypesOf(Object.class)
187+
.stream()
186188
.filter(a -> a.isAnnotationPresent(Constraint.class))
187189
.collect(Collectors.toSet());
188190
}

0 commit comments

Comments
 (0)