Skip to content

Commit

Permalink
Add missing test for mutation fields
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Jan 12, 2024
1 parent 75ddf68 commit 0d1054c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/__tests__/selection.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ test('infers simple fields', () => {
expectTypeOf<expected>().toEqualTypeOf<actual>();
});

test('infers mutation fields', () => {
type mutation = parseDocument</* GraphQL */ `
mutation ToggleTodo ($id: ID!) {
toggleTodo(id: $id) {
id
}
}
`>;

type actual = getDocumentType<mutation, schema>;
type expected = { toggleTodo: { id: string | number } | null };

expectTypeOf<expected>().toEqualTypeOf<actual>();
});

test('infers unknown fields as `unknown`', () => {
type query = parseDocument</* GraphQL */ `
query { unknown, unknownObj { __typename } }
Expand Down

0 comments on commit 0d1054c

Please sign in to comment.