graphql.DirectivesUtil Maven / Gradle / Ivy
package graphql;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLDirective;
import graphql.util.FpKit;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Internal
public class DirectivesUtil {
public static Map directivesByName(List directiveList) {
return FpKit.getByName(directiveList, GraphQLDirective::getName, FpKit.mergeFirst());
}
public static Optional directiveByName(List directives, String directiveName) {
for (GraphQLDirective directive : directives) {
if (directive.getName().equals(directiveName)) {
return Optional.of(directive);
}
}
return Optional.empty();
}
public static Optional directiveWithArg(List directiveList, String directiveName, String argumentName) {
GraphQLDirective directive = directiveByName(directiveList, directiveName).orElse(null);
GraphQLArgument argument = null;
if (directive != null) {
argument = directive.getArgument(argumentName);
}
return Optional.ofNullable(argument);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy