genqlient
genqlient copied to clipboard
Be more permissive of duplicate fields with different selections
GraphQL allows you to do this:
query {
myField {
# these two get merged:
subField { subSubField1 subSubField2 }
subField { subSubField3 subSubField4 }
}
}
and even this:
query {
myField {
subField { subSubField1 subSubField2 }
... on OnePossibleConcreteType {
subField { subSubField3 subSubField4 } # merged in if the concrete type matches
}
}
}
(Well, it sometimes lets you do that. The rules are very arcane.))
For now, to simplify things, I've simply disallowed any duplicate fields of composite type in genqlient. There's no structural limitation preventing us from adding support, if we do find it useful, we'd just need to do more complicated merging in convertSelectionSet. (there would be some subtleties to handle around type naming.) But my guess is this is quite rare (and easy enough to work around).
Note that we do already allow duplicated leaf fields, because they're much easier to deduplicate. We also allow duplicated fields if at least one is in a name fragment, because in that case we needn't merge the fields at all.