Skip to content

Commit 0e77994

Browse files
andimarekclaude
andcommitted
Add test for good faith disabled with custom validation predicate
Covers the lambda branch in GraphQL.validate() where good faith is disabled and an existing custom rule predicate also excludes a rule, exercising the && short-circuit path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b18910d commit 0e77994

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/test/groovy/graphql/introspection/GoodFaithIntrospectionTest.groovy

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ package graphql.introspection
22

33
import graphql.ExecutionInput
44
import graphql.ExecutionResult
5+
import graphql.ParseAndValidate
56
import graphql.TestUtil
67
import graphql.execution.CoercedVariables
78
import graphql.language.Document
89
import graphql.normalized.ExecutableNormalizedOperationFactory
10+
import graphql.validation.OperationValidationRule
911
import graphql.validation.QueryComplexityLimits
1012
import spock.lang.Specification
1113

@@ -143,6 +145,24 @@ class GoodFaithIntrospectionTest extends Specification {
143145
er.errors.isEmpty()
144146
}
145147

148+
def "disabling good faith composes with custom validation rule predicates"() {
149+
given:
150+
// Custom predicate that disables a specific rule
151+
def customPredicate = { OperationValidationRule rule -> rule != OperationValidationRule.KNOWN_ARGUMENT_NAMES } as java.util.function.Predicate
152+
153+
when:
154+
def context = [
155+
(GoodFaithIntrospection.GOOD_FAITH_INTROSPECTION_DISABLED) : true,
156+
(ParseAndValidate.INTERNAL_VALIDATION_PREDICATE_HINT) : customPredicate
157+
]
158+
ExecutionInput executionInput = ExecutionInput.newExecutionInput("{ normalField }")
159+
.graphQLContext(context).build()
160+
ExecutionResult er = graphql.execute(executionInput)
161+
162+
then:
163+
er.errors.isEmpty()
164+
}
165+
146166
def "can be disabled per request"() {
147167
when:
148168
def context = [(GoodFaithIntrospection.GOOD_FAITH_INTROSPECTION_DISABLED): true]

0 commit comments

Comments
 (0)