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

graphql.validation.rules.DeferredDirectiveAbstractRule Maven / Gradle / Ivy

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

import graphql.Directives;
import graphql.Internal;
import graphql.language.Directive;
import graphql.language.Node;
import graphql.schema.GraphQLCompositeType;
import graphql.schema.GraphQLFieldDefinition;
import graphql.validation.AbstractRule;
import graphql.validation.ValidationContext;
import graphql.validation.ValidationErrorCollector;

import java.util.List;

@Internal
public abstract class DeferredDirectiveAbstractRule extends AbstractRule {

    public DeferredDirectiveAbstractRule(ValidationContext validationContext, ValidationErrorCollector validationErrorCollector) {
        super(validationContext, validationErrorCollector);
    }

    @Override
    public void checkDirective(Directive directive, List ancestors) {
        if (!directive.getName().equals(Directives.DeferDirective.getName())) {
            return;
        }

        GraphQLCompositeType parentType = getValidationContext().getParentType();
        GraphQLFieldDefinition fieldDef = getValidationContext().getFieldDef();
        if (parentType == null || fieldDef == null) {
            // some previous rule will have caught this
            return;
        }
        onDeferredDirective(directive, ancestors, parentType, fieldDef);
    }

    protected abstract void onDeferredDirective(Directive deferredDirective, List ancestors, GraphQLCompositeType parentType, GraphQLFieldDefinition fieldDef);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy