graphql.kickstart.execution.instrumentation.FieldLevelTrackingApproach Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of graphql-java-kickstart Show documentation
Show all versions of graphql-java-kickstart Show documentation
relay.js-compatible GraphQL servlet
package graphql.kickstart.execution.instrumentation;
import graphql.Internal;
import graphql.execution.ExecutionId;
import graphql.execution.instrumentation.InstrumentationState;
import org.dataloader.DataLoaderRegistry;
/**
* This approach uses field level tracking to achieve its aims of making the data loader more efficient.
* Can handle new/concurrent executions using the same sets of dataloaders, attempting to batch load calls together.
*/
@Internal
public class FieldLevelTrackingApproach extends AbstractTrackingApproach {
public FieldLevelTrackingApproach(DataLoaderRegistry dataLoaderRegistry) {
super(dataLoaderRegistry);
}
public InstrumentationState createState(ExecutionId executionId) {
synchronized (getStack()) {
if (getStack().contains(executionId)) {
throw new RuntimeException(String.format("Execution id %s already in active execution", executionId));
}
getStack().addExecution(executionId);
return null;
}
}
}