All Downloads are FREE. Search and download functionalities are using the official Maven repository.

graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentationState Maven / Gradle / Ivy

There is a newer version: 230521-nf-execution
Show newest version
package graphql.execution.instrumentation.dataloader;

import graphql.execution.instrumentation.InstrumentationState;
import org.dataloader.DataLoaderRegistry;
import org.slf4j.Logger;

/**
 * A base class that keeps track of whether aggressive batching can be used
 */
public class DataLoaderDispatcherInstrumentationState implements InstrumentationState {

    private final FieldLevelTrackingApproach approach;
    private final DataLoaderRegistry dataLoaderRegistry;
    private final InstrumentationState state;
    private final boolean hasNoDataLoaders;
    private boolean aggressivelyBatching = true;

    public DataLoaderDispatcherInstrumentationState(Logger log, DataLoaderRegistry dataLoaderRegistry) {

        this.dataLoaderRegistry = dataLoaderRegistry;
        this.approach = new FieldLevelTrackingApproach(log, dataLoaderRegistry);
        this.state = approach.createState();
        hasNoDataLoaders = dataLoaderRegistry.getKeys().isEmpty();

    }

    boolean isAggressivelyBatching() {
        return aggressivelyBatching;
    }

    void setAggressivelyBatching(boolean aggressivelyBatching) {
        this.aggressivelyBatching = aggressivelyBatching;
    }

    FieldLevelTrackingApproach getApproach() {
        return approach;
    }

    DataLoaderRegistry getDataLoaderRegistry() {
        return dataLoaderRegistry;
    }

    boolean hasNoDataLoaders() {
        return hasNoDataLoaders;
    }

    InstrumentationState getState() {
        return state;
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy