@@ -13,6 +13,8 @@ import { buildGraphqlMutation, buildGraphqlQuery } from '../zod-graphql-query-bu
13
13
export type FakeGraphqlClient = GraphqlClient & {
14
14
readonly inspectOperationPayload : ( index : number ) => GraphqlOverHttpOperationRequestPayload ;
15
15
readonly inspectFirstOperationPayload : ( ) => GraphqlOverHttpOperationRequestPayload ;
16
+ readonly inspectOperationOptions : ( index : number ) => OperationOptions ;
17
+ readonly inspectFirstOperationOptions : ( ) => OperationOptions ;
16
18
} ;
17
19
18
20
type FakeSuccessData = {
@@ -33,6 +35,7 @@ type FakeClientOptions = {
33
35
export function createFakeGraphqlClient ( clientOptions : FakeClientOptions = { } ) : FakeGraphqlClient {
34
36
const { results = [ ] } = clientOptions ;
35
37
const operationPayloads : GraphqlOverHttpOperationRequestPayload [ ] = [ ] ;
38
+ const operationOptions : OperationOptions [ ] = [ ] ;
36
39
const defaultResult : FakeResult = { data : { } } ;
37
40
38
41
async function collectOperation < Schema extends QuerySchema > (
@@ -61,6 +64,7 @@ export function createFakeGraphqlClient(clientOptions: FakeClientOptions = {}):
61
64
query : serializedQuery ,
62
65
variables : variableValues
63
66
} ) ;
67
+ operationOptions . push ( options ) ;
64
68
65
69
if ( result . error !== undefined ) {
66
70
return { success : false , errorDetails : result . error } ;
@@ -91,6 +95,15 @@ export function createFakeGraphqlClient(clientOptions: FakeClientOptions = {}):
91
95
return payload ;
92
96
}
93
97
98
+ function inspectOperationOptions ( index : number ) : OperationOptions {
99
+ const operationOption = operationOptions [ index ] ;
100
+ if ( operationOption === undefined ) {
101
+ throw new Error ( `No operationOption at index ${ index } recorded` ) ;
102
+ }
103
+
104
+ return operationOption ;
105
+ }
106
+
94
107
return {
95
108
query,
96
109
@@ -118,6 +131,10 @@ export function createFakeGraphqlClient(clientOptions: FakeClientOptions = {}):
118
131
119
132
inspectFirstOperationPayload ( ) {
120
133
return inspectOperationPayload ( 0 ) ;
134
+ } ,
135
+ inspectOperationOptions,
136
+ inspectFirstOperationOptions ( ) {
137
+ return inspectOperationOptions ( 0 ) ;
121
138
}
122
139
} ;
123
140
}
0 commit comments