@@ -144,24 +144,34 @@ export function createOperator<ThisConfig extends IConfiguration>(
144144 } ,
145145 context . value ,
146146 ( err , value , options = { } ) => {
147- clearTimeout ( asyncTimeout )
148- if ( options . path ) {
149- const newContext = createContext (
150- context ,
151- value ,
152- context . execution . path &&
153- context . execution . path . concat ( options . path . name )
154- )
155- const nextWithPath = createNextPath ( next )
156- options . path . operator ( err , newContext , ( ...args ) => {
157- operatorStopped ( context , args [ 1 ] . value )
158- nextWithPath ( ...args )
159- } )
147+ function run ( err , value ) {
148+ if ( options . path ) {
149+ const newContext = createContext (
150+ context ,
151+ value ,
152+ context . execution . path &&
153+ context . execution . path . concat ( options . path . name )
154+ )
155+ const nextWithPath = createNextPath ( next )
156+ options . path . operator ( err , newContext , ( ...args ) => {
157+ operatorStopped ( context , args [ 1 ] . value )
158+ nextWithPath ( ...args )
159+ } )
160+ } else {
161+ operatorStopped ( context , err || value , {
162+ isSkipped : err ? true : options . isSkipped ,
163+ } )
164+ next ( err , createContext ( context , value ) )
165+ }
166+ }
167+
168+ if ( value && value instanceof Promise ) {
169+ value
170+ . then ( ( promiseValue ) => run ( err , promiseValue ) )
171+ . catch ( ( promiseError ) => run ( promiseError , promiseError ) )
160172 } else {
161- operatorStopped ( context , err || value , {
162- isSkipped : err ? true : options . isSkipped ,
163- } )
164- next ( err , createContext ( context , value ) )
173+ clearTimeout ( asyncTimeout )
174+ run ( err , value )
165175 }
166176 } ,
167177 ( err , value ) => {
@@ -234,11 +244,21 @@ export function createMutationOperator<ThisConfig extends IConfiguration>(
234244 ? context . value
235245 : context . execution . scopeValue ( context . value , mutationTree ) ,
236246 ( err , value , options = { } ) => {
237- clearTimeout ( asyncTimeout )
238- operatorStopped ( context , err || value , {
239- isSkipped : err ? true : options . isSkipped ,
240- } )
241- next ( err , createContext ( context , value ) )
247+ function run ( err , value ) {
248+ operatorStopped ( context , err || value , {
249+ isSkipped : err ? true : options . isSkipped ,
250+ } )
251+ next ( err , createContext ( context , value ) )
252+ }
253+
254+ if ( value && value instanceof Promise ) {
255+ value
256+ . then ( ( promiseValue ) => run ( err , promiseValue ) )
257+ . catch ( ( promiseError ) => run ( promiseError , promiseError ) )
258+ } else {
259+ clearTimeout ( asyncTimeout )
260+ run ( err , value )
261+ }
242262 } ,
243263 ( err , value ) => {
244264 clearTimeout ( asyncTimeout )
0 commit comments