Reject cyclical SDL directive definitions#4385
Conversation
Test ReportTest Results
Code Coverage (Java 25)
|
| for (DirectiveDefinition directiveDefinition : directiveDefinitions) { | ||
| result.putIfAbsent(directiveDefinition.getName(), directiveDefinition); | ||
| } | ||
| return result; |
There was a problem hiding this comment.
Use graphql.util.FpKit#getByName(java.util.List<T>, java.util.function.Function<T,java.lang.String>, java.util.function.BinaryOperator<T>)
Less code
There was a problem hiding this comment.
Done in c58ab2a. I replaced the hand-written directiveDefinitionsByName(...) map builder with FpKit#getByName(..., mergeFirst()), preserving the existing first-definition-wins behavior while removing the extra helper code.
| for (DirectiveDefinition directiveDefinition : directiveDefinitions) { | ||
| result.put(directiveDefinition.getName(), directiveReferences(directiveDefinition, directiveDefinitionsByName)); | ||
| } | ||
| return result; |
There was a problem hiding this comment.
I think you can use graphql.util.FpKit#getByName(java.util.List, java.util.function.Function<T,java.lang.String>, java.util.function.BinaryOperator)
There was a problem hiding this comment.
Done in c58ab2a. directiveReferencesByName(...) now consumes the map produced by FpKit#getByName(..., mergeFirst()) instead of rebuilding the directive-definition map itself, so the cycle checker uses the shared local utility as suggested.
179dacf to
b2b2d8f
Compare
b2b2d8f to
c58ab2a
Compare
Summary
Fixes #4201
Testing