Polishing Javadoc and in security sample

This commit is contained in:
Rossen Stoyanchev
2021-07-05 14:31:58 +01:00
parent cc61c4baad
commit 16656d623f
8 changed files with 36 additions and 35 deletions

View File

@@ -2,8 +2,6 @@ package io.spring.sample.graphql;
import java.math.BigDecimal;
import reactor.core.publisher.Mono;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;

View File

@@ -1,8 +1,12 @@
package io.spring.sample.graphql;
import java.util.Collections;
import java.util.List;
import graphql.GraphQLError;
import graphql.GraphqlErrorBuilder;
import graphql.schema.DataFetchingEnvironment;
import org.springframework.graphql.execution.ErrorType;
import org.springframework.graphql.execution.SyncDataFetcherExceptionResolver;
import org.springframework.security.access.AccessDeniedException;
@@ -15,9 +19,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import java.util.Arrays;
import java.util.List;
@Component
public class SecurityDataFetcherExceptionResolver implements SyncDataFetcherExceptionResolver {
@@ -45,7 +46,7 @@ public class SecurityDataFetcherExceptionResolver implements SyncDataFetcherExce
}
private List<GraphQLError> unauthorized(DataFetchingEnvironment environment) {
return Arrays.asList(
return Collections.singletonList(
GraphqlErrorBuilder.newError(environment)
.errorType(ErrorType.UNAUTHORIZED)
.message("Unauthorized")
@@ -53,7 +54,7 @@ public class SecurityDataFetcherExceptionResolver implements SyncDataFetcherExce
}
private List<GraphQLError> forbidden(DataFetchingEnvironment environment) {
return Arrays.asList(
return Collections.singletonList(
GraphqlErrorBuilder.newError(environment)
.errorType(ErrorType.FORBIDDEN)
.message("Forbidden")