File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -139,4 +139,54 @@ describe('perform', () => {
139
139
}
140
140
` ) ;
141
141
} ) ;
142
+
143
+ it ( 'should replace params in onPerform plugin' , async ( ) => {
144
+ const getEnveloped = envelop ( {
145
+ ...graphqlFuncs ,
146
+ plugins : [
147
+ useSchema ( schema ) ,
148
+ {
149
+ onPerform : ( { setParams } ) => {
150
+ setParams ( { query : '{ hello }' } ) ;
151
+ } ,
152
+ } ,
153
+ ] ,
154
+ } ) ;
155
+
156
+ const { perform } = getEnveloped ( ) ;
157
+ const result = await perform ( { query : 'subscribe { greetings }' } ) ;
158
+ assertSingleExecutionValue ( result ) ;
159
+
160
+ expect ( result ) . toMatchInlineSnapshot ( `
161
+ Object {
162
+ "data": Object {
163
+ "hello": "world",
164
+ },
165
+ }
166
+ ` ) ;
167
+ } ) ;
168
+
169
+ it ( 'should replace result in onPerformDone plugin' , async ( ) => {
170
+ const replacedResult = { data : { something : 'else' } } ;
171
+
172
+ const getEnveloped = envelop ( {
173
+ ...graphqlFuncs ,
174
+ plugins : [
175
+ useSchema ( schema ) ,
176
+ {
177
+ onPerform : ( ) => ( {
178
+ onPerformDone : ( { setResult } ) => {
179
+ setResult ( replacedResult ) ;
180
+ } ,
181
+ } ) ,
182
+ } ,
183
+ ] ,
184
+ } ) ;
185
+
186
+ const { perform } = getEnveloped ( ) ;
187
+ const result = await perform ( { query : '{ hello }' } ) ;
188
+ assertSingleExecutionValue ( result ) ;
189
+
190
+ expect ( result ) . toBe ( replacedResult ) ;
191
+ } ) ;
142
192
} ) ;
You can’t perform that action at this time.
0 commit comments