Skip to content

Commit 02374cf

Browse files
committed
Reproduce problem with test
1 parent db47a74 commit 02374cf

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

src/test/groovy/graphql/execution/ConditionalNodesTest.groovy

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,18 @@ class ConditionalNodesTest extends Specification {
111111
type Query {
112112
in : String
113113
out : String
114+
pet : Pet
115+
}
116+
117+
type Pet {
118+
name: String
119+
favouriteSnack: String
114120
}
115121
"""
116122
DataFetcher df = { DataFetchingEnvironment env -> env.getFieldDefinition().name }
117-
def graphQL = TestUtil.graphQL(sdl, [Query: ["in": df, "out": df]]).build()
123+
def graphQL = TestUtil.graphQL(sdl, [
124+
Query: ["in": df, "out": df, "pet": (DataFetcher<Map>) { [ : ] } ],
125+
Pet: ["name": df, "favouriteSnack": df]]).build()
118126
ConditionalNodeDecision customDecision = new ConditionalNodeDecision() {
119127
@Override
120128
boolean shouldInclude(ConditionalNodeDecisionEnvironment env) {
@@ -183,6 +191,27 @@ class ConditionalNodesTest extends Specification {
183191

184192
then:
185193
er["data"] == ["in": "in", "out": "out"]
194+
195+
// TODO: this test demonstrates that the GraphQLContext is missing for Pet
196+
// and therefore, fields are being incorrectly included
197+
when:
198+
ei = ExecutionInput.newExecutionInput()
199+
.graphQLContext(contextMap)
200+
.query("""
201+
query q {
202+
in
203+
pet {
204+
name
205+
favouriteSnack @featureFlag(flagName : "OFF")
206+
}
207+
}
208+
"""
209+
).build()
210+
er = graphQL.execute(ei)
211+
212+
then:
213+
// TODO: favouriteSnack should not appear in the data
214+
er["data"] == ["in": "in", "pet": ["name": "name"]]
186215
}
187216

188217
private ArrayList<Directive> directive(String name, Argument argument) {

0 commit comments

Comments
 (0)