( args: ExecutionArgs<TData, TVariables, TContext>, )
| 264 | * a GraphQLError will be thrown immediately explaining the invalid input. |
| 265 | */ |
| 266 | export function execute<TData = any, TVariables = any, TContext = any>( |
| 267 | args: ExecutionArgs<TData, TVariables, TContext>, |
| 268 | ): MaybePromise<SingularExecutionResult<TData> | IncrementalExecutionResults<TData>> { |
| 269 | // If a valid execution context cannot be created due to incorrect arguments, |
| 270 | // a "Response" with only errors is returned. |
| 271 | const exeContext = buildExecutionContext(args); |
| 272 | |
| 273 | // Return early errors if execution context failed. |
| 274 | if (!('schema' in exeContext)) { |
| 275 | return { |
| 276 | errors: exeContext.map(e => { |
| 277 | Object.defineProperty(e, 'extensions', { |
| 278 | value: { |
| 279 | ...e.extensions, |
| 280 | http: { |
| 281 | ...(e.extensions?.['http'] || {}), |
| 282 | status: 400, |
| 283 | }, |
| 284 | }, |
| 285 | }); |
| 286 | return e; |
| 287 | }), |
| 288 | }; |
| 289 | } |
| 290 | |
| 291 | return executeImpl(exeContext); |
| 292 | } |
| 293 | |
| 294 | function executeImpl<TData = any, TVariables = any, TContext = any>( |
| 295 | exeContext: ExecutionContext<TVariables, TContext>, |
searching dependent graphs…