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

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

package graphql.validation.rules;

import graphql.language.Argument;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLFieldDefinition;
import graphql.validation.*;


public class KnownArgumentNames extends AbstractRule {

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


    @Override
    public void checkArgument(Argument argument) {
        GraphQLFieldDefinition fieldDef = getValidationContext().getFieldDef();
        if (fieldDef == null) return;
        GraphQLArgument fieldArgument = fieldDef.getArgument(argument.getName());
        if (fieldArgument == null) {
            String message = String.format("Unknown argument %s", argument.getName());
            addError(new ValidationError(ValidationErrorType.UnknownArgument, argument.getSourceLocation(), message));
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy