We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d476674 commit 674da60Copy full SHA for 674da60
src/handlers.ts
@@ -146,6 +146,25 @@ function createHandlerFromSchema<TResolvers>(
146
});
147
}
148
149
+ function withMocks(mocks: IMocks<TResolvers>) {
150
+ const oldSchema = testSchema;
151
+
152
+ testSchema = addMocksToSchema({
153
+ schema: oldSchema,
154
+ mocks: mocks,
155
+ });
156
157
+ function restore() {
158
+ testSchema = oldSchema;
159
+ }
160
161
+ return Object.assign(restore, {
162
+ [Symbol.dispose]() {
163
+ restore();
164
+ },
165
166
167
168
function replaceDelay(newDelay: Delay) {
169
const oldDelay = _delay;
170
_delay = newDelay;
@@ -269,6 +288,7 @@ function createHandlerFromSchema<TResolvers>(
269
288
replaceSchema,
270
289
replaceDelay,
271
290
withResolvers,
291
+ withMocks,
272
292
},
273
293
);
274
294
0 commit comments