Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def getDevelopmentVersion() {
}

def reactiveStreamsVersion = '1.0.3'
def slf4jVersion = '2.0.7'
def releaseVersion = System.env.RELEASE_VERSION
def antlrVersion = '4.11.1' // https://mvnrepository.com/artifact/org.antlr/antlr4-runtime
def guavaVersion = '32.1.2-jre'
Expand Down Expand Up @@ -101,7 +100,6 @@ jar {
dependencies {
compileOnly 'org.jetbrains:annotations:24.1.0'
implementation 'org.antlr:antlr4-runtime:' + antlrVersion
implementation 'org.slf4j:slf4j-api:' + slf4jVersion
api 'com.graphql-java:java-dataloader:3.2.2'
api 'org.reactivestreams:reactive-streams:' + reactiveStreamsVersion
antlr 'org.antlr:antlr4:' + antlrVersion
Expand All @@ -113,7 +111,6 @@ dependencies {
testImplementation 'com.google.code.gson:gson:2.10.1'
testImplementation 'org.eclipse.jetty:jetty-server:11.0.15'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.16.1'
testImplementation 'org.slf4j:slf4j-simple:' + slf4jVersion
testImplementation 'org.awaitility:awaitility-groovy:4.2.0'
testImplementation 'com.github.javafaker:javafaker:1.0.2'

Expand Down
37 changes: 1 addition & 36 deletions src/main/java/graphql/GraphQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
import graphql.execution.preparsed.PreparsedDocumentProvider;
import graphql.language.Document;
import graphql.schema.GraphQLSchema;
import graphql.util.LogKit;
import graphql.validation.ValidationError;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -91,9 +88,6 @@
@PublicApi
public class GraphQL {

private static final Logger log = LoggerFactory.getLogger(GraphQL.class);
private static final Logger logNotSafe = LogKit.getNotPrivacySafeLogger(GraphQL.class);

private final GraphQLSchema graphQLSchema;
private final ExecutionStrategy queryStrategy;
private final ExecutionStrategy mutationStrategy;
Expand Down Expand Up @@ -419,9 +413,6 @@ public CompletableFuture<ExecutionResult> executeAsync(UnaryOperator<ExecutionIn
* @return a promise to an {@link ExecutionResult} which can include errors
*/
public CompletableFuture<ExecutionResult> executeAsync(ExecutionInput executionInput) {
if (logNotSafe.isDebugEnabled()) {
logNotSafe.debug("Executing request. operation name: '{}'. query: '{}'. variables '{}'", executionInput.getOperationName(), executionInput.getQuery(), executionInput.getVariables());
}
ExecutionInput executionInputWithId = ensureInputHasId(executionInput);

CompletableFuture<InstrumentationState> instrumentationStateCF = instrumentation.createStateAsync(new InstrumentationCreateStateParameters(this.graphQLSchema, executionInput));
Expand Down Expand Up @@ -496,25 +487,17 @@ private PreparsedDocumentEntry parseAndValidate(AtomicReference<ExecutionInput>
ExecutionInput executionInput = executionInputRef.get();
String query = executionInput.getQuery();

if (logNotSafe.isDebugEnabled()) {
logNotSafe.debug("Parsing query: '{}'...", query);
}
ParseAndValidateResult parseResult = parse(executionInput, graphQLSchema, instrumentationState);
if (parseResult.isFailure()) {
logNotSafe.warn("Query did not parse : '{}'", executionInput.getQuery());
return new PreparsedDocumentEntry(parseResult.getSyntaxException().toInvalidSyntaxError());
} else {
final Document document = parseResult.getDocument();
// they may have changed the document and the variables via instrumentation so update the reference to it
executionInput = executionInput.transform(builder -> builder.variables(parseResult.getVariables()));
executionInputRef.set(executionInput);

if (logNotSafe.isDebugEnabled()) {
logNotSafe.debug("Validating query: '{}'", query);
}
final List<ValidationError> errors = validate(executionInput, document, graphQLSchema, instrumentationState);
if (!errors.isEmpty()) {
logNotSafe.warn("Query did not validate : '{}'", query);
return new PreparsedDocumentEntry(document, errors);
}

Expand Down Expand Up @@ -562,25 +545,7 @@ private CompletableFuture<ExecutionResult> execute(ExecutionInput executionInput
Execution execution = new Execution(queryStrategy, mutationStrategy, subscriptionStrategy, instrumentation, valueUnboxer);
ExecutionId executionId = executionInput.getExecutionId();

if (logNotSafe.isDebugEnabled()) {
logNotSafe.debug("Executing '{}'. operation name: '{}'. query: '{}'. variables '{}'", executionId, executionInput.getOperationName(), executionInput.getQuery(), executionInput.getVariables());
}
CompletableFuture<ExecutionResult> future = execution.execute(document, graphQLSchema, executionId, executionInput, instrumentationState);
future = future.whenComplete((result, throwable) -> {
if (throwable != null) {
logNotSafe.error(String.format("Execution '%s' threw exception when executing : query : '%s'. variables '%s'", executionId, executionInput.getQuery(), executionInput.getVariables()), throwable);
} else {
if (log.isDebugEnabled()) {
int errorCount = result.getErrors().size();
if (errorCount > 0) {
log.debug("Execution '{}' completed with '{}' errors", executionId, errorCount);
} else {
log.debug("Execution '{}' completed with zero errors", executionId);
}
}
}
});
return future;
return execution.execute(document, graphQLSchema, executionId, executionInput, instrumentationState);
}

private static Instrumentation checkInstrumentationDefaultState(Instrumentation instrumentation, boolean doNotAddDefaultInstrumentations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import graphql.execution.instrumentation.parameters.InstrumentationValidationParameters;
import graphql.validation.ValidationError;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
Expand All @@ -32,8 +30,6 @@
@PublicApi
public class MaxQueryComplexityInstrumentation extends SimplePerformantInstrumentation {

private static final Logger log = LoggerFactory.getLogger(MaxQueryComplexityInstrumentation.class);

private final int maxComplexity;
private final FieldComplexityCalculator fieldComplexityCalculator;
private final Function<QueryComplexityInfo, Boolean> maxQueryComplexityExceededFunction;
Expand Down Expand Up @@ -100,9 +96,6 @@ public InstrumentationState createState(InstrumentationCreateStateParameters par
State state = ofState(rawState);
QueryComplexityCalculator queryComplexityCalculator = newQueryComplexityCalculator(instrumentationExecuteOperationParameters.getExecutionContext());
int totalComplexity = queryComplexityCalculator.calculate();
if (log.isDebugEnabled()) {
log.debug("Query complexity: {}", totalComplexity);
}
if (totalComplexity > maxComplexity) {
QueryComplexityInfo queryComplexityInfo = QueryComplexityInfo.newQueryComplexityInfo()
.complexity(totalComplexity)
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/graphql/execution/Execution.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLSchema;
import graphql.schema.impl.SchemaUtil;
import graphql.util.LogKit;
import org.slf4j.Logger;

import java.util.Collections;
import java.util.List;
Expand All @@ -37,8 +35,6 @@

@Internal
public class Execution {
private static final Logger logNotSafe = LogKit.getNotPrivacySafeLogger(Execution.class);

private final FieldCollector fieldCollector = new FieldCollector();
private final ExecutionStrategy queryStrategy;
private final ExecutionStrategy mutationStrategy;
Expand Down Expand Up @@ -155,9 +151,6 @@ private CompletableFuture<ExecutionResult> executeOperation(ExecutionContext exe
CompletableFuture<ExecutionResult> result;
try {
ExecutionStrategy executionStrategy = executionContext.getStrategy(operation);
if (logNotSafe.isDebugEnabled()) {
logNotSafe.debug("Executing '{}' query operation: '{}' using '{}' execution strategy", executionContext.getExecutionId(), operation, executionStrategy.getClass().getName());
}
result = executionStrategy.execute(executionContext, parameters);
} catch (NonNullableFieldWasNullException e) {
// this means it was non-null types all the way from an offending non-null type
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/graphql/execution/ExecutionStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
import graphql.schema.GraphQLType;
import graphql.schema.LightDataFetcher;
import graphql.util.FpKit;
import graphql.util.LogKit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -126,9 +123,6 @@
@SuppressWarnings("FutureReturnValueIgnored")
public abstract class ExecutionStrategy {

private static final Logger log = LoggerFactory.getLogger(ExecutionStrategy.class);
private static final Logger logNotSafe = LogKit.getNotPrivacySafeLogger(ExecutionStrategy.class);

protected final FieldCollector fieldCollector = new FieldCollector();
protected final ExecutionStepInfoFactory executionStepInfoFactory = new ExecutionStepInfoFactory();
private final ResolveType resolvedType = new ResolveType();
Expand Down Expand Up @@ -312,9 +306,6 @@ private CompletableFuture<Object> invokeDataFetcher(ExecutionContext executionCo
}
fetchedValue = Async.toCompletableFuture(fetchedValueRaw);
} catch (Exception e) {
if (logNotSafe.isDebugEnabled()) {
logNotSafe.debug(String.format("'%s', field '%s' fetch threw exception", executionContext.getExecutionId(), parameters.getPath()), e);
}
fetchedValue = Async.exceptionallyCompletedFuture(e);
}
return fetchedValue;
Expand Down Expand Up @@ -428,10 +419,6 @@ protected FieldValueInfo completeField(ExecutionContext executionContext, Execut
.nonNullFieldValidator(nonNullableFieldValidator)
);

if (log.isDebugEnabled()) {
log.debug("'{}' completing field '{}'...", executionContext.getExecutionId(), executionStepInfo.getPath());
}

FieldValueInfo fieldValueInfo = completeValue(executionContext, newParameters);

CompletableFuture<ExecutionResult> executionResultFuture = fieldValueInfo.getFieldValue();
Expand Down Expand Up @@ -493,9 +480,7 @@ protected FieldValueInfo completeValue(ExecutionContext executionContext, Execut

private void handleUnresolvedTypeProblem(ExecutionContext context, ExecutionStrategyParameters parameters, UnresolvedTypeException e) {
UnresolvedTypeError error = new UnresolvedTypeError(parameters.getPath(), parameters.getExecutionStepInfo(), e);
logNotSafe.warn(error.getMessage(), e);
context.addError(error);

}

/**
Expand Down Expand Up @@ -706,10 +691,7 @@ protected CompletableFuture<ExecutionResult> completeValueForObject(ExecutionCon
@SuppressWarnings("SameReturnValue")
private Object handleCoercionProblem(ExecutionContext context, ExecutionStrategyParameters parameters, CoercingSerializeException e) {
SerializationError error = new SerializationError(parameters.getPath(), e);
logNotSafe.warn(error.getMessage(), e);
context.addError(error);


return null;
}

Expand All @@ -734,7 +716,6 @@ protected Iterable<Object> toIterable(ExecutionContext context, ExecutionStrateg

private void handleTypeMismatchProblem(ExecutionContext context, ExecutionStrategyParameters parameters, Object result) {
TypeMismatchError error = new TypeMismatchError(parameters.getPath(), parameters.getExecutionStepInfo().getUnwrappedNonNullType());
logNotSafe.warn("{} got {}", error.getMessage(), result.getClass());
context.addError(error);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import graphql.ExceptionWhileDataFetching;
import graphql.PublicApi;
import graphql.language.SourceLocation;
import graphql.util.LogKit;
import org.slf4j.Logger;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
Expand All @@ -16,8 +14,6 @@
@PublicApi
public class SimpleDataFetcherExceptionHandler implements DataFetcherExceptionHandler {

private static final Logger logNotSafe = LogKit.getNotPrivacySafeLogger(SimpleDataFetcherExceptionHandler.class);

static final SimpleDataFetcherExceptionHandler defaultImpl = new SimpleDataFetcherExceptionHandler();

private DataFetcherExceptionHandlerResult handleExceptionImpl(DataFetcherExceptionHandlerParameters handlerParameters) {
Expand All @@ -43,7 +39,6 @@ public CompletableFuture<DataFetcherExceptionHandlerResult> handleException(Data
* @param exception the exception that happened
*/
protected void logException(ExceptionWhileDataFetching error, Throwable exception) {
logNotSafe.warn(error.getMessage(), exception);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
*/
@PublicApi
public class DataLoaderDispatcherInstrumentation extends SimplePerformantInstrumentation {

private static final Logger log = LoggerFactory.getLogger(DataLoaderDispatcherInstrumentation.class);

private final DataLoaderDispatcherInstrumentationOptions options;

/**
Expand All @@ -73,7 +70,7 @@ public DataLoaderDispatcherInstrumentation(DataLoaderDispatcherInstrumentationOp

@Override
public InstrumentationState createState(InstrumentationCreateStateParameters parameters) {
return new DataLoaderDispatcherInstrumentationState(log, parameters.getExecutionInput().getDataLoaderRegistry());
return new DataLoaderDispatcherInstrumentationState(parameters.getExecutionInput().getDataLoaderRegistry());
}

@Override
Expand Down Expand Up @@ -158,10 +155,6 @@ private boolean isDataLoaderCompatibleExecution(ExecutionContext executionContex
Map<Object, Object> dataLoaderStats = buildStatsMap(state);
statsMap.put("dataloader", dataLoaderStats);

if (log.isDebugEnabled()) {
log.debug("Data loader stats : {}", dataLoaderStats);
}

return CompletableFuture.completedFuture(new ExecutionResultImpl(executionResult.getData(), executionResult.getErrors(), statsMap));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import graphql.execution.instrumentation.InstrumentationState;
import org.dataloader.DataLoader;
import org.dataloader.DataLoaderRegistry;
import org.slf4j.Logger;

import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
Expand Down Expand Up @@ -45,9 +44,9 @@ public DataLoaderRegistry unregister(String key) {
private volatile boolean aggressivelyBatching = true;
private volatile boolean hasNoDataLoaders;

public DataLoaderDispatcherInstrumentationState(Logger log, DataLoaderRegistry dataLoaderRegistry) {
public DataLoaderDispatcherInstrumentationState(DataLoaderRegistry dataLoaderRegistry) {
this.dataLoaderRegistry = new AtomicReference<>(dataLoaderRegistry);
this.approach = new FieldLevelTrackingApproach(log, this::getDataLoaderRegistry);
this.approach = new FieldLevelTrackingApproach(this::getDataLoaderRegistry);
this.state = approach.createState();
hasNoDataLoaders = checkForNoDataLoader(dataLoaderRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchParameters;
import graphql.util.LockKit;
import org.dataloader.DataLoaderRegistry;
import org.slf4j.Logger;

import java.util.LinkedHashSet;
import java.util.List;
Expand All @@ -26,7 +25,6 @@
@Internal
public class FieldLevelTrackingApproach {
private final Supplier<DataLoaderRegistry> dataLoaderRegistrySupplier;
private final Logger log;

private static class CallStack implements InstrumentationState {

Expand Down Expand Up @@ -112,9 +110,8 @@ public void clearAndMarkCurrentLevelAsReady(int level) {
}
}

public FieldLevelTrackingApproach(Logger log, Supplier<DataLoaderRegistry> dataLoaderRegistrySupplier) {
public FieldLevelTrackingApproach(Supplier<DataLoaderRegistry> dataLoaderRegistrySupplier) {
this.dataLoaderRegistrySupplier = dataLoaderRegistrySupplier;
this.log = log;
}

public InstrumentationState createState() {
Expand Down Expand Up @@ -236,9 +233,6 @@ private boolean levelReady(CallStack callStack, int level) {

void dispatch() {
DataLoaderRegistry dataLoaderRegistry = getDataLoaderRegistry();
if (log.isDebugEnabled()) {
log.debug("Dispatching data loaders ({})", dataLoaderRegistry.getKeys());
}
dataLoaderRegistry.dispatchAll();
}

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/graphql/schema/PropertyFetchingImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
*/
@Internal
public class PropertyFetchingImpl {
private static final Logger log = LoggerFactory.getLogger(PropertyFetchingImpl.class);

private final AtomicBoolean USE_SET_ACCESSIBLE = new AtomicBoolean(true);
private final AtomicBoolean USE_LAMBDA_FACTORY = new AtomicBoolean(true);
private final AtomicBoolean USE_NEGATIVE_CACHE = new AtomicBoolean(true);
Expand Down Expand Up @@ -126,8 +124,6 @@ public Object getPropertyValue(String propertyName, Object object, GraphQLType g
// are preventing the Meta Lambda from working. So let's continue with
// old skool reflection and if it's all broken there then it will eventually
// end up negatively cached
log.debug("Unable to invoke fast Meta Lambda for `{}` - Falling back to reflection", object.getClass().getName(), ignored);

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import graphql.schema.CoercingParseLiteralException;
import graphql.schema.GraphQLScalarType;
import graphql.schema.idl.errors.DirectiveIllegalArgumentTypeError;
import graphql.util.LogKit;
import org.slf4j.Logger;

import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -64,8 +62,6 @@
@Internal
class ArgValueOfAllowedTypeChecker {

private static final Logger logNotSafe = LogKit.getNotPrivacySafeLogger(ArgValueOfAllowedTypeChecker.class);

private final Directive directive;
private final Node<?> element;
private final String elementName;
Expand Down Expand Up @@ -291,9 +287,6 @@ private boolean isArgumentValueScalarLiteral(GraphQLScalarType scalarType, Value
scalarType.getCoercing().parseLiteral(instanceValue, CoercedVariables.emptyVariables(), GraphQLContext.getDefault(), Locale.getDefault());
return true;
} catch (CoercingParseLiteralException ex) {
if (logNotSafe.isDebugEnabled()) {
logNotSafe.debug("Attempted parsing literal into '{}' but got the following error: ", scalarType.getName(), ex);
}
return false;
}
}
Expand Down
Loading