Skip to content

Commit 00dbea1

Browse files
committed
use variables for abstract types in tests
1 parent d89b1ae commit 00dbea1

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/execution/__tests__/abstract-test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -698,46 +698,48 @@ describe('Execute: Handles execution of abstract types', () => {
698698
};
699699
}
700700

701+
const namedType = assertInterfaceType(schema.getType('Named'));
701702
// FIXME: workaround since we can't inject resolveType into SDL
702-
assertInterfaceType(schema.getType('Named')).resolveType = () => 'Animal';
703+
namedType.resolveType = () => 'Animal';
703704
expectError().toEqual(
704705
'Abstract type resolution for "Named" for field "Query.named" failed. Interface type "Animal" is not a subtype of encountered interface type "Named".',
705706
);
706707

708+
const petType = assertInterfaceType(schema.getType('Pet'));
707709
// FIXME: workaround since we can't inject resolveType into SDL
708-
assertInterfaceType(schema.getType('Named')).resolveType = () => 'Pet';
709-
assertInterfaceType(schema.getType('Pet')).resolveType = () => undefined;
710+
namedType.resolveType = () => 'Pet';
711+
petType.resolveType = () => undefined;
710712
expectError().toEqual(
711713
'Abstract type resolution for "Named" for field "Query.named" failed. Encountered abstract type "Pet" must resolve to an Object or Interface type at runtime. Either the "Pet" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.',
712714
);
713715

714716
// FIXME: workaround since we can't inject resolveType into SDL
715-
assertInterfaceType(schema.getType('Pet')).resolveType = () => 'Human';
717+
petType.resolveType = () => 'Human';
716718
expectError().toEqual(
717719
'Abstract type resolution for "Named" for field "Query.named" failed. Encountered abstract type "Pet" was resolved to a type "Human" that does not exist inside the schema.',
718720
);
719721

720722
// FIXME: workaround since we can't inject resolveType into SDL
721-
assertInterfaceType(schema.getType('Pet')).resolveType = () => 'String';
723+
petType.resolveType = () => 'String';
722724
expectError().toEqual(
723725
'Abstract type resolution for "Named" for field "Query.named" failed. Encountered abstract type "Pet" was resolved to a non-object type "String".',
724726
);
725727

726728
// FIXME: workaround since we can't inject resolveType into SDL
727-
assertInterfaceType(schema.getType('Pet')).resolveType = () => '__Schema';
729+
petType.resolveType = () => '__Schema';
728730
expectError().toEqual(
729731
'Abstract type resolution for "Named" for field "Query.named" failed. Runtime Object type "__Schema" is not a possible type for encountered abstract type "Pet".',
730732
);
731733

732734
// FIXME: workaround since we can't inject resolveType into SDL
733735
// @ts-expect-error
734-
assertInterfaceType(schema.getType('Pet')).resolveType = () => [];
736+
petType.resolveType = () => [];
735737
expectError().toEqual(
736738
'Abstract type resolution for "Named" for field "Query.named" with value {} failed. Encountered abstract type "Pet" must resolve to an Object or Interface type at runtime, received "[]".',
737739
);
738740

739741
// FIXME: workaround since we can't inject resolveType into SDL
740-
assertInterfaceType(schema.getType('Pet')).resolveType = () => 'Pet';
742+
petType.resolveType = () => 'Pet';
741743
expectError().toEqual(
742744
'Abstract type resolution for "Named" for field "Query.named" failed. Encountered abstract type "Pet" resolved to "Pet", causing a cycle.',
743745
);

0 commit comments

Comments
 (0)