Skip to content

Commit

Permalink
QuickFix for apollographql#3415 - fragments. Todo: tests and cleaner fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GroofyIT committed Oct 17, 2019
1 parent faba52c commit e2afde3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/apollo-gateway/src/buildQueryPlan.ts
Expand Up @@ -403,15 +403,18 @@ function splitFields(
// If parent type is an object type, we can directly look for the right
// group.
const group = groupForField(field as Field<GraphQLObjectType>);
group.fields.push(
const fieldsForParentType = fieldsForResponseName.filter(f=>f.parentType===parentType);
if(fieldsForParentType.length>0) {
group.fields.push(
completeField(
context,
parentType,
group,
path,
fieldsForResponseName,
fieldsForParentType,
),
);
}
} else {
// For interfaces however, we need to look at all possible runtime types.

Expand Down Expand Up @@ -440,6 +443,8 @@ function splitFields(
// We add the field separately for each runtime parent type.
for (const [group, runtimeParentTypes] of groupsByRuntimeParentTypes) {
for (const runtimeParentType of runtimeParentTypes) {
const fieldsForRuntimeParentType = fieldsForResponseName.filter(f=>f.parentType===runtimeParentType);
if(fieldsForRuntimeParentType.length>0) {
group.fields.push(
completeField(
context,
Expand All @@ -451,6 +456,7 @@ function splitFields(
);
}
}
}
}
}
}
Expand Down

0 comments on commit e2afde3

Please sign in to comment.