Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/main/java/graphql/schema/idl/SchemaTypeDirectivesChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import graphql.GraphQLError;
import graphql.Internal;
import graphql.collect.ImmutableKit;
import graphql.introspection.Introspection.DirectiveLocation;
import graphql.language.Argument;
import graphql.language.Directive;
Expand Down Expand Up @@ -148,10 +147,13 @@ private void checkDirectives(DirectiveLocation expectedLocation, List<GraphQLErr
});
}

private boolean inRightLocation(DirectiveLocation expectedLocation, DirectiveDefinition directiveDefinition) {
List<String> names = ImmutableKit.map(directiveDefinition.getDirectiveLocations(),
it -> it.getName().toUpperCase());
return names.contains(expectedLocation.name().toUpperCase());
private static boolean inRightLocation(DirectiveLocation expectedLocation, DirectiveDefinition directiveDefinition) {
for (graphql.language.DirectiveLocation location : directiveDefinition.getDirectiveLocations()) {
if (location.getName().equalsIgnoreCase(expectedLocation.name())) {
return true;
}
}
return false;
}

private void checkDirectiveArguments(List<GraphQLError> errors, TypeDefinitionRegistry typeRegistry, Node<?> element, String elementName, Directive directive, DirectiveDefinition directiveDefinition) {
Expand All @@ -175,7 +177,7 @@ private void checkDirectiveArguments(List<GraphQLError> errors, TypeDefinitionRe
});
}

private boolean isNoNullArgWithoutDefaultValue(InputValueDefinition definitionArgument) {
private static boolean isNoNullArgWithoutDefaultValue(InputValueDefinition definitionArgument) {
return definitionArgument.getType() instanceof NonNullType && definitionArgument.getDefaultValue() == null;
}

Expand All @@ -192,7 +194,7 @@ private void commonCheck(Collection<DirectiveDefinition> directiveDefinitions, L
});
}

private void assertTypeName(NamedNode<?> node, List<GraphQLError> errors) {
private static void assertTypeName(NamedNode<?> node, List<GraphQLError> errors) {
if (node.getName().length() >= 2 && node.getName().startsWith("__")) {
errors.add((new IllegalNameError(node)));
}
Expand All @@ -215,7 +217,7 @@ public void assertExistAndIsInputType(InputValueDefinition definition, List<Grap
}
}

private TypeDefinition<?> findTypeDefFromRegistry(String typeName, TypeDefinitionRegistry typeRegistry) {
private static TypeDefinition<?> findTypeDefFromRegistry(String typeName, TypeDefinitionRegistry typeRegistry) {
TypeDefinition<?> typeDefinition = typeRegistry.getTypeOrNull(typeName);
if (typeDefinition != null) {
return typeDefinition;
Expand Down
Loading