visitFragmentDefinitionNode method
Visit FragmentDefinitionNode
.
Implementation
@override
FragmentDefinitionNode visitFragmentDefinitionNode(
FragmentDefinitionNode node,
) {
final hasTypename = node.selectionSet.selections
.whereType<FieldNode>()
.any((node) => node.name.value == '__typename');
if (hasTypename) return node;
return FragmentDefinitionNode(
name: node.name,
typeCondition: node.typeCondition,
directives: node.directives,
selectionSet: SelectionSetNode(
selections: <SelectionNode>[
FieldNode(
name: NameNode(value: '__typename'),
),
...node.selectionSet.selections,
],
),
);
}