Polishing Javadoc and in security sample
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user