11import { graphql } from './graphql'
2+ import {
3+ GetUserDetailDocument ,
4+ GetUserDetailQueryVariables ,
5+ LoginDocument ,
6+ LoginMutationVariables ,
7+ } from './graphql.test-data'
28
39test ( 'exports supported GraphQL operation types' , ( ) => {
410 expect ( graphql ) . toBeDefined ( )
@@ -9,3 +15,25 @@ test('exports supported GraphQL operation types', () => {
915 'link' ,
1016 ] )
1117} )
18+
19+ test ( 'pass proper type to request variable and data payload parameter for query' , ( ) => {
20+ const op = graphql . query ( GetUserDetailDocument , ( req , res , ctx ) => {
21+ // If type doesn't match, this should fail compilation
22+ const variables : GetUserDetailQueryVariables = req . variables
23+
24+ // MANUAL VERIFICATION: intellisense on `ctx.data` should be of type `DataContext<GetUserDetailQuery>`.
25+ // Not sure how to test this.
26+ ctx . data
27+ } )
28+ } )
29+
30+ test ( 'pass proper type to request variable and data payload parameter for mutation' , ( ) => {
31+ const op = graphql . mutation ( LoginDocument , ( req , res , ctx ) => {
32+ // If type doesn't match, this should fail compilation
33+ const variables : LoginMutationVariables = req . variables
34+
35+ // MANUAL VERIFICATION: intellisense on `ctx.data` should be of type `DataContext<LoginMutation>`.
36+ // Not sure how to test this.
37+ ctx . data
38+ } )
39+ } )
0 commit comments