MCPcopy Create free account
hub / github.com/Effect-TS/effect / operation

Function operation

packages/effect/src/graphql/GraphQLProtocol.ts:988–1001  ·  view source on GitHub ↗
(request: GraphQLRequest)

Source from the content-addressed store, hash-verified

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) =>

Callers 2

executeFunction · 0.70
Graph.test.tsFile · 0.50

Calls 6

releaseFunction · 0.70
sendFunction · 0.70
requestBodyFunction · 0.70
awaitMethod · 0.65
failMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected