Skip to content

Commit

Permalink
Add field parent types to usedFields
Browse files Browse the repository at this point in the history
  • Loading branch information
BoD committed Apr 3, 2024
1 parent 00a9fc8 commit fb6d626
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ internal class IrOperationsBuilder(
val condition: BooleanExpression<BVariable>,
val selections: List<GQLSelection>,
val parentType: String,
val definitionHasArguments: Boolean
) {
val responseName = alias ?: name
}
Expand Down Expand Up @@ -530,7 +531,8 @@ internal class IrOperationsBuilder(
semanticNonNulls = semanticNonNulls,
forceOptional = gqlField.directives.optionalValue(schema) == true,
parentType = fieldWithParent.parentType,
catch = gqlField.findCatch(fieldDefinition, schema)
catch = gqlField.findCatch(fieldDefinition, schema),
definitionHasArguments = fieldDefinition.arguments.isNotEmpty()
)
}.groupBy {
it.responseName
Expand Down Expand Up @@ -596,6 +598,11 @@ internal class IrOperationsBuilder(
*/
usedFields.putType(first.type.rawType().name)

// When a field with arguments is selected, its parent type is referenced in the compiled selections
if (first.definitionHasArguments) {
usedFields.putType(first.parentType)
}

val irType = first
.type
.toIr(schema)
Expand Down

0 comments on commit fb6d626

Please sign in to comment.