1
1
import { describe , expectTypeOf } from 'vitest'
2
2
import { test } from '../../../../tests/_/helpers.js'
3
3
import { gql } from '../../6_helpers/gql.js'
4
- import type { RawResolveOutputReturnRootType } from '../handleOutput.js'
5
4
6
5
describe ( `TypedQueryDocumentNode` , ( ) => {
7
6
describe ( `data` , ( ) => {
8
7
const document = gql < { id : string } , { } > `query { id }`
9
- test ( `envelope data is typed` , ( { kitchenSink : g } ) => {
10
- type ExpectedType = RawResolveOutputReturnRootType < typeof g . _ . context . config , { id : string } >
11
- expectTypeOf ( g . raw ( { document } ) ) . resolves . toEqualTypeOf < ExpectedType > ( )
8
+ test ( `envelope data is typed` , async ( { kitchenSink : g } ) => {
9
+ expectTypeOf ( await g . raw ( { document } ) ) . toEqualTypeOf < null | { id : string } > ( )
12
10
} )
13
11
test ( `variables are not allowed to be passed in` , async ( { kitchenSink : g } ) => {
14
12
// @ts -expect-error - variables not allowed.
@@ -19,9 +17,7 @@ describe(`TypedQueryDocumentNode`, () => {
19
17
describe ( `data + optional variables` , ( ) => {
20
18
const document = gql < { id : string } , { filter ?: boolean } > `query { id }`
21
19
test ( `envelope data is typed` , ( { kitchenSink : g } ) => {
22
- expectTypeOf ( g . raw ( { document } ) ) . resolves . toEqualTypeOf <
23
- RawResolveOutputReturnRootType < typeof g . _ . context . config , { id : string } >
24
- > ( )
20
+ expectTypeOf ( g . raw ( { document } ) ) . resolves . toEqualTypeOf < { id : string } | null > ( )
25
21
} )
26
22
test ( `variables are typed and allowed to be passed in or omitted` , async ( { kitchenSink : g } ) => {
27
23
// Expect no type errors below
0 commit comments