Skip to content

Commit d45f7d8

Browse files
JoviDeCroockbenjie
andcommitted
Update execute.ts
Co-authored-by: Benjie <benjie@jemjie.com>
1 parent 1c2cee6 commit d45f7d8

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

.c8rc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"src/jsutils/ObjMap.ts",
99
"src/jsutils/PromiseOrValue.ts",
1010
"src/utilities/assertValidName.ts",
11-
"src/utilities/typedQueryDocumentNode.ts"
11+
"src/utilities/typedQueryDocumentNode.ts",
12+
"src/execution/__tests__/union-interface-test.ts"
1213
],
1314
"clean": true,
1415
"temp-directory": "coverage",

src/execution/__tests__/union-interface-test.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,10 @@ const TypeA = new GraphQLObjectType({
169169
nameA: { type: GraphQLString },
170170
}),
171171
isTypeOf: (_value, _context, _info) =>
172-
new Promise(
173-
(_resolve, reject) =>
174-
void setTimeout(
175-
() => void reject(new Error("TypeA_isTypeOf_rejected")),
176-
10,
177-
),
172+
new Promise((_resolve, reject) =>
173+
// eslint-disable-next-line
174+
setTimeout(() => reject(new Error('TypeA_isTypeOf_rejected')), 10),
178175
),
179-
},
180176
});
181177

182178
const TypeB = new GraphQLObjectType({
@@ -186,9 +182,7 @@ const TypeB = new GraphQLObjectType({
186182
id: { type: GraphQLString },
187183
nameB: { type: GraphQLString },
188184
}),
189-
isTypeOf: (value: any, _context, _info) => {
190-
return value.id === 'b';
191-
},
185+
isTypeOf: (value: any, _context, _info) => value.id === 'b',
192186
});
193187

194188
const queryTypeWithSearchable = new GraphQLObjectType({
@@ -640,6 +634,7 @@ describe('Execute: Union and intersection types', () => {
640634
const unhandledRejectionListener = (reason: any) => {
641635
unhandledRejection = reason;
642636
};
637+
// eslint-disable-next-line
643638
process.on('unhandledRejection', unhandledRejectionListener);
644639
/* c8 ignore end */
645640

@@ -648,7 +643,7 @@ describe('Execute: Union and intersection types', () => {
648643
document,
649644
});
650645

651-
expect(result.errors).to.be.undefined;
646+
expect(result.errors).to.equal(undefined);
652647
expect(result.data).to.deep.equal({
653648
search: {
654649
__typename: 'TypeB',
@@ -658,10 +653,12 @@ describe('Execute: Union and intersection types', () => {
658653
});
659654

660655
// Give the TypeA promise a chance to reject and the listener to fire
656+
// eslint-disable-next-line
661657
await new Promise((resolve) => setTimeout(resolve, 20));
662658

659+
// eslint-disable-next-line
663660
process.removeListener('unhandledRejection', unhandledRejectionListener);
664661

665-
expect(unhandledRejection).to.be.null;
662+
expect(unhandledRejection).to.equal(null);
666663
});
667664
});

src/execution/execute.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,12 @@ export const defaultTypeResolver: GraphQLTypeResolver<unknown, unknown> =
10031003
promisedIsTypeOfResults[i] = isTypeOfResult;
10041004
} else if (isTypeOfResult) {
10051005
if (promisedIsTypeOfResults.length) {
1006-
Promise.allSettled(promisedIsTypeOfResults);
1006+
// Explicitly ignore any promise rejections
1007+
Promise.allSettled(promisedIsTypeOfResults)
1008+
/* c8 ignore next 3 */
1009+
.catch(() => {
1010+
// Do nothing
1011+
});
10071012
}
10081013
return type.name;
10091014
}

0 commit comments

Comments
 (0)