@@ -143,25 +143,37 @@ class ContextVisitor extends RecursiveVisitor {
143143 _visitInFragment (fragmentDef, fragmentName);
144144 return ;
145145 }
146- if (context.currentType is ! ObjectTypeDefinitionNode ) {
147- return ;
148- }
149- // Current type condition
150- final typeCondition = fragmentDef.typeCondition;
146+ if (context.currentType is ObjectTypeDefinitionNode ) {
147+ // Current type condition
148+ final typeCondition = fragmentDef.typeCondition;
151149
152- // Find concrete types of the type conditions.
153- final typeConditionConcreteTypes = context.schema
154- .lookupConcreteTypes (typeCondition.on .name)
155- .map ((e) => e.name)
156- .toSet ();
150+ // Find concrete types of the type conditions.
151+ final typeConditionConcreteTypes = context.schema
152+ .lookupConcreteTypes (typeCondition.on .name)
153+ .map ((e) => e.name)
154+ .toSet ();
157155
158- if (! typeConditionConcreteTypes.contains (context.currentType.name)) {
156+ if (! typeConditionConcreteTypes.contains (context.currentType.name)) {
157+ return ;
158+ }
159+ final typedFragmentName = fragmentName.withSegment (
160+ TypeNameSegment (context.currentType.name),
161+ );
162+ _visitInFragment (fragmentDef, typedFragmentName);
159163 return ;
160164 }
161- final typedFragmentName = fragmentName.withSegment (
162- TypeNameSegment (context.currentType.name),
163- );
164- _visitInFragment (fragmentDef, typedFragmentName);
165+
166+ final currentType = context.currentType;
167+ if (currentType is InterfaceTypeDefinitionNode ) {
168+ final typeConditionName = fragmentDef.typeCondition.on .name;
169+ final currentTypeInterfaces = currentType.interfaces
170+ .map ((e) => e.name)
171+ .toSet ();
172+ if (! currentTypeInterfaces.contains (typeConditionName)) {
173+ return ;
174+ }
175+ _visitInFragment (fragmentDef, fragmentName);
176+ }
165177 }
166178
167179 @override
0 commit comments