Skip to content

Commit 1f6b64e

Browse files
IvanGoncharovleebyron
authored andcommitted
Fix how TypeInfo handles inline fragments without type (#1041)
1 parent 997bd8f commit 1f6b64e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/language/__tests__/visitor-test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,9 @@ describe('Visitor', () => {
10701070

10711071
const typeInfo = new TypeInfo(testSchema);
10721072

1073-
const ast = parse('{ human(id: 4) { name, pets { name }, unknown } }');
1073+
const ast = parse(
1074+
'{ human(id: 4) { name, pets { ... { name } }, unknown } }'
1075+
);
10741076
visit(ast, visitWithTypeInfo(typeInfo, {
10751077
enter(node) {
10761078
const parentType = typeInfo.getParentType();
@@ -1122,10 +1124,14 @@ describe('Visitor', () => {
11221124
[ 'enter', 'Name', 'pets', 'Human', '[Pet]', null ],
11231125
[ 'leave', 'Name', 'pets', 'Human', '[Pet]', null ],
11241126
[ 'enter', 'SelectionSet', null, 'Pet', '[Pet]', null ],
1127+
[ 'enter', 'InlineFragment', null, 'Pet', 'Pet', null ],
1128+
[ 'enter', 'SelectionSet', null, 'Pet', 'Pet', null ],
11251129
[ 'enter', 'Field', null, 'Pet', 'String', null ],
11261130
[ 'enter', 'Name', 'name', 'Pet', 'String', null ],
11271131
[ 'leave', 'Name', 'name', 'Pet', 'String', null ],
11281132
[ 'leave', 'Field', null, 'Pet', 'String', null ],
1133+
[ 'leave', 'SelectionSet', null, 'Pet', 'Pet', null ],
1134+
[ 'leave', 'InlineFragment', null, 'Pet', 'Pet', null ],
11291135
[ 'leave', 'SelectionSet', null, 'Pet', '[Pet]', null ],
11301136
[ 'leave', 'Field', null, 'Human', '[Pet]', null ],
11311137
[ 'enter', 'Field', null, 'Human', null, null ],

src/utilities/TypeInfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class TypeInfo {
149149
const typeConditionAST = node.typeCondition;
150150
const outputType = typeConditionAST ?
151151
typeFromAST(schema, typeConditionAST) :
152-
this.getType();
152+
getNamedType(this.getType());
153153
this._typeStack.push(
154154
isOutputType(outputType) ? outputType : undefined
155155
);

0 commit comments

Comments
 (0)