| 986 | ) |
| 987 | |
| 988 | const operation = (request: GraphQLRequest): Stream.Stream<{ readonly body: unknown }, TransportError> => |
| 989 | Stream.unwrap(Effect.gen(function*() { |
| 990 | const [id, conn] = yield* Effect.acquireRelease(register, ([id, conn]) => release(id, conn)) |
| 991 | yield* Deferred.await(conn.ack) |
| 992 | if (conn.error !== undefined) { |
| 993 | return yield* Effect.fail(conn.error) |
| 994 | } |
| 995 | const queue = yield* Queue.unbounded<{ readonly body: unknown }, TransportError | Cause.Done>() |
| 996 | operations.set(id, { queue, connection: conn }) |
| 997 | // Per-call `request.headers` and `request.urlParams` are ignored: |
| 998 | // graphql-ws has no per-operation headers or URL. |
| 999 | yield* send({ id, type: "subscribe", payload: requestBody(request) }) |
| 1000 | return Stream.fromQueue(queue) |
| 1001 | })) |
| 1002 | |
| 1003 | const execute = (request: GraphQLRequest): Effect.Effect<{ readonly body: unknown }, TransportError> => |
| 1004 | Effect.flatMap(Stream.runHead(operation(request)), (result) => |