@@ -24,6 +24,7 @@ export interface UseQueryOptions<
24
24
suspense ?: boolean ;
25
25
staleWhileRevalidate ?: boolean | object | number | string | null ;
26
26
onError ?: OnErrorHandler ;
27
+ operationName ?: string ;
27
28
prepare ?: ( helpers : UseQueryPrepareHelpers < GeneratedSchema > ) => void ;
28
29
}
29
30
@@ -80,6 +81,7 @@ export function createUseQuery<
80
81
staleWhileRevalidate = defaultStaleWhileRevalidate ,
81
82
onError,
82
83
prepare,
84
+ operationName,
83
85
} : UseQueryOptions < GeneratedSchema > = { } ) : UseQueryReturnValue < GeneratedSchema > {
84
86
const [ $state ] = React . useState < Writeable < UseQueryState > > ( ( ) => {
85
87
const state : Writeable < UseQueryState > = {
@@ -101,6 +103,18 @@ export function createUseQuery<
101
103
updateOnFetchPromise : true ,
102
104
} ) ;
103
105
106
+ const removeOperationNameInterceptor = React . useMemo ( ( ) => {
107
+ const interceptor = interceptorManager . createInterceptor ( ) ;
108
+
109
+ interceptor . selectionAddListeners . add ( ( selection ) => {
110
+ selection . operationName = operationName ;
111
+ } ) ;
112
+
113
+ return ( ) => {
114
+ interceptorManager . removeInterceptor ( interceptor ) ;
115
+ } ;
116
+ } , [ operationName ] ) ;
117
+
104
118
if ( prepare ) {
105
119
try {
106
120
prepare ( prepareHelpers ) ;
@@ -112,6 +126,8 @@ export function createUseQuery<
112
126
}
113
127
}
114
128
129
+ useIsomorphicLayoutEffect ( removeOperationNameInterceptor ) ;
130
+
115
131
useIsomorphicLayoutEffect ( ( ) => {
116
132
return scheduler . errors . subscribeErrors ( ( ev ) => {
117
133
switch ( ev . type ) {
0 commit comments