Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/test/groovy/graphql/StarWarsData.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ class StarWarsData {
GraphQLObjectType getType(TypeResolutionEnvironment env) {
def id = env.getObject().id
if (humanData[id] != null)
return StarWarsSchema.humanType
return env.getSchema().getType(StarWarsSchema.humanType.name)
if (droidData[id] != null)
return StarWarsSchema.droidType
return env.getSchema().getType(StarWarsSchema.droidType.name)
return null
}
}
Expand Down
40 changes: 40 additions & 0 deletions src/test/groovy/graphql/schema/DataFetcherSelectionTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ class DataFetcherSelectionTest extends Specification {
[
"hero" : captureSelection(new StaticDataFetcher(StarWarsData.getArtoo())),
"human": captureSelection(StarWarsData.getHumanDataFetcher()),
"humanCharacter": captureSelection(StarWarsData.getHumanDataFetcher()),
"droid": captureSelection(StarWarsData.getDroidDataFetcher())
])
)
.type(newTypeWiring("Human")
.dataFetcher("friends", captureSelection(StarWarsData.getFriendsDataFetcher()))
.dataFetcher("homePlanet", captureSelection(new StaticDataFetcher("Home")))
)
.type(newTypeWiring("Droid")
.dataFetcher("friends", captureSelection(StarWarsData.getFriendsDataFetcher()))
Expand Down Expand Up @@ -259,4 +261,42 @@ class DataFetcherSelectionTest extends Specification {

}

def "field selection can be captured for inline fragments when output type is an interface/union"() {

def query = """
query CAPTURED_VIA_DF {

humanCharacter(id: "1003") {
id
__typename
friends {
id
otherId: id
}
... on Human {
homePlanet
}
}
}
"""


expect:
when:
GraphQL.newGraphQL(executableStarWarsSchema).build().execute(query).data

then:

// should homePlanet field be included?
captureMap.keySet() == [
"id",
"__typename",
"friends",
"friends/id",
"friends/otherId",
"otherId",
"homePlanet"
].toSet()
}

}
1 change: 1 addition & 0 deletions src/test/resources/starWarsSchemaWithArguments.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ schema {
type QueryType {
hero(episode: Episode): Character
human(id : String) : Human
humanCharacter(id : String) : Character
droid(id: ID!): Droid
}

Expand Down