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

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

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


import graphql.language.FragmentDefinition;
import graphql.language.FragmentSpread;
import graphql.validation.*;

public class KnownFragmentNames extends AbstractRule {

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

    @Override
    public void checkFragmentSpread(FragmentSpread fragmentSpread) {
        FragmentDefinition fragmentDefinition = getValidationContext().getFragment(fragmentSpread.getName());
        if (fragmentDefinition == null) {
            String message = String.format("Undefined fragment %s", fragmentSpread.getName());
            addError(new ValidationError(ValidationErrorType.UndefinedFragment, fragmentSpread.getSourceLocation(), message));
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy