| 383 | // restates its type here. Force POST and the resolved URL apply only at the |
| 384 | // transport boundary. |
| 385 | const execute = ( |
| 386 | index: number, |
| 387 | request: GraphQLRequest, |
| 388 | forcePost: boolean, |
| 389 | resolvedUrl: internalGraphQL.ResolvedUrl |
| 390 | ): Effect.Effect<ExecutionResult, GraphQL.Error<Op>, GraphQLMiddleware.Requires<GraphQL.Middleware<Op>>> => |
| 391 | index === chain.length |
| 392 | ? protocol.execute(request).pipe( |
| 393 | forcePost ? Effect.provideService(internalGraphQL.ForcePost, true) : identity, |
| 394 | resolvedUrl === undefined ? identity : Effect.provideService(internalGraphQL.ResolvedUrl, resolvedUrl), |
| 395 | Effect.mapError(fail), |
| 396 | Effect.flatMap(decodeResponse) |
| 397 | ) |
| 398 | : chain[index].execute({ |
| 399 | operation, |
| 400 | request, |
| 401 | next: (request) => |
| 402 | execute(index + 1, request, forcePost, resolvedUrl) as Effect.Effect< |
| 403 | ExecutionResult, |
| 404 | GraphQLClientError | Types.unhandled |
| 405 | > |
| 406 | }) as Effect.Effect<ExecutionResult, GraphQL.Error<Op>, GraphQLMiddleware.Requires<GraphQL.Middleware<Op>>> |
| 407 | |
| 408 | // Hands a resolver batch's URL to the transport only, so calls made by |
| 409 | // middleware resolve their own. |