effect 4.0.3 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/AGENTS.md +24 -0
  2. package/CLAUDE.md +24 -0
  3. package/ai-docs/package.json +2 -2
  4. package/ai-docs/src/52_graphql/10_basics.ts +111 -0
  5. package/ai-docs/src/52_graphql/20_testing.ts +45 -0
  6. package/ai-docs/src/52_graphql/30_batching.ts +116 -0
  7. package/ai-docs/src/52_graphql/40_aliased-batching.ts +122 -0
  8. package/ai-docs/src/52_graphql/50_errors-and-retries.ts +74 -0
  9. package/ai-docs/src/52_graphql/index.md +6 -0
  10. package/dist/Context.d.ts.map +1 -1
  11. package/dist/Context.js +9 -0
  12. package/dist/Context.js.map +1 -1
  13. package/dist/RequestResolver.d.ts.map +1 -1
  14. package/dist/RequestResolver.js +4 -10
  15. package/dist/RequestResolver.js.map +1 -1
  16. package/dist/Scheduler.d.ts +9 -0
  17. package/dist/Scheduler.d.ts.map +1 -1
  18. package/dist/Scheduler.js +9 -0
  19. package/dist/Scheduler.js.map +1 -1
  20. package/dist/Schema.d.ts +8 -0
  21. package/dist/Schema.d.ts.map +1 -1
  22. package/dist/Schema.js +7 -0
  23. package/dist/Schema.js.map +1 -1
  24. package/dist/SchemaGetter.d.ts +4 -0
  25. package/dist/SchemaGetter.d.ts.map +1 -1
  26. package/dist/SchemaGetter.js +52 -33
  27. package/dist/SchemaGetter.js.map +1 -1
  28. package/dist/Sink.d.ts.map +1 -1
  29. package/dist/Sink.js +38 -17
  30. package/dist/Sink.js.map +1 -1
  31. package/dist/Stream.d.ts +11 -0
  32. package/dist/Stream.d.ts.map +1 -1
  33. package/dist/Stream.js +16 -1
  34. package/dist/Stream.js.map +1 -1
  35. package/dist/Utils.js +8 -3
  36. package/dist/Utils.js.map +1 -1
  37. package/dist/ai/AnthropicStructuredOutput.js +0 -2
  38. package/dist/ai/AnthropicStructuredOutput.js.map +1 -1
  39. package/dist/ai/Chat.d.ts +2 -2
  40. package/dist/ai/Chat.d.ts.map +1 -1
  41. package/dist/ai/LanguageModel.d.ts +38 -7
  42. package/dist/ai/LanguageModel.d.ts.map +1 -1
  43. package/dist/ai/LanguageModel.js +25 -7
  44. package/dist/ai/LanguageModel.js.map +1 -1
  45. package/dist/ai/McpServer.d.ts +55 -0
  46. package/dist/ai/McpServer.d.ts.map +1 -1
  47. package/dist/ai/McpServer.js +132 -22
  48. package/dist/ai/McpServer.js.map +1 -1
  49. package/dist/ai/Prompt.d.ts.map +1 -1
  50. package/dist/ai/Prompt.js +28 -5
  51. package/dist/ai/Prompt.js.map +1 -1
  52. package/dist/ai/Response.d.ts +4 -3
  53. package/dist/ai/Response.d.ts.map +1 -1
  54. package/dist/ai/Response.js.map +1 -1
  55. package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  56. package/dist/cluster/ClusterWorkflowEngine.js +46 -8
  57. package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
  58. package/dist/cluster/Sharding.d.ts.map +1 -1
  59. package/dist/cluster/Sharding.js +6 -4
  60. package/dist/cluster/Sharding.js.map +1 -1
  61. package/dist/encoding/Sse.d.ts +6 -0
  62. package/dist/encoding/Sse.d.ts.map +1 -1
  63. package/dist/encoding/Sse.js +62 -70
  64. package/dist/encoding/Sse.js.map +1 -1
  65. package/dist/graphql/GraphQL.d.ts +349 -0
  66. package/dist/graphql/GraphQL.d.ts.map +1 -0
  67. package/dist/graphql/GraphQL.js +207 -0
  68. package/dist/graphql/GraphQL.js.map +1 -0
  69. package/dist/graphql/GraphQLClient.d.ts +562 -0
  70. package/dist/graphql/GraphQLClient.d.ts.map +1 -0
  71. package/dist/graphql/GraphQLClient.js +498 -0
  72. package/dist/graphql/GraphQLClient.js.map +1 -0
  73. package/dist/graphql/GraphQLClientError.d.ts +445 -0
  74. package/dist/graphql/GraphQLClientError.d.ts.map +1 -0
  75. package/dist/graphql/GraphQLClientError.js +479 -0
  76. package/dist/graphql/GraphQLClientError.js.map +1 -0
  77. package/dist/graphql/GraphQLGroup.d.ts +118 -0
  78. package/dist/graphql/GraphQLGroup.d.ts.map +1 -0
  79. package/dist/graphql/GraphQLGroup.js +109 -0
  80. package/dist/graphql/GraphQLGroup.js.map +1 -0
  81. package/dist/graphql/GraphQLMiddleware.d.ts +249 -0
  82. package/dist/graphql/GraphQLMiddleware.d.ts.map +1 -0
  83. package/dist/graphql/GraphQLMiddleware.js +130 -0
  84. package/dist/graphql/GraphQLMiddleware.js.map +1 -0
  85. package/dist/graphql/GraphQLProtocol.d.ts +731 -0
  86. package/dist/graphql/GraphQLProtocol.d.ts.map +1 -0
  87. package/dist/graphql/GraphQLProtocol.js +719 -0
  88. package/dist/graphql/GraphQLProtocol.js.map +1 -0
  89. package/dist/graphql/GraphQLResolver.d.ts +453 -0
  90. package/dist/graphql/GraphQLResolver.d.ts.map +1 -0
  91. package/dist/graphql/GraphQLResolver.js +552 -0
  92. package/dist/graphql/GraphQLResolver.js.map +1 -0
  93. package/dist/graphql/index.d.ts +40 -0
  94. package/dist/graphql/index.d.ts.map +1 -0
  95. package/dist/graphql/index.js +41 -0
  96. package/dist/graphql/index.js.map +1 -0
  97. package/dist/http/HttpClient.d.ts +15 -0
  98. package/dist/http/HttpClient.d.ts.map +1 -1
  99. package/dist/http/HttpClient.js +24 -10
  100. package/dist/http/HttpClient.js.map +1 -1
  101. package/dist/http/HttpEffect.d.ts.map +1 -1
  102. package/dist/http/HttpEffect.js +14 -7
  103. package/dist/http/HttpEffect.js.map +1 -1
  104. package/dist/http/HttpMiddleware.d.ts.map +1 -1
  105. package/dist/http/HttpMiddleware.js +31 -32
  106. package/dist/http/HttpMiddleware.js.map +1 -1
  107. package/dist/http/HttpRouter.d.ts +35 -0
  108. package/dist/http/HttpRouter.d.ts.map +1 -1
  109. package/dist/http/HttpRouter.js +35 -0
  110. package/dist/http/HttpRouter.js.map +1 -1
  111. package/dist/http/HttpServerResponse.d.ts +8 -6
  112. package/dist/http/HttpServerResponse.d.ts.map +1 -1
  113. package/dist/http/HttpServerResponse.js +27 -16
  114. package/dist/http/HttpServerResponse.js.map +1 -1
  115. package/dist/http/Multipart.d.ts.map +1 -1
  116. package/dist/http/Multipart.js +15 -1
  117. package/dist/http/Multipart.js.map +1 -1
  118. package/dist/http-api/HttpApiScalar.d.ts +5 -0
  119. package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
  120. package/dist/http-api/HttpApiScalar.js.map +1 -1
  121. package/dist/internal/dateTime.js +40 -35
  122. package/dist/internal/dateTime.js.map +1 -1
  123. package/dist/internal/effect.js +8 -3
  124. package/dist/internal/effect.js.map +1 -1
  125. package/dist/internal/graphql.d.ts +2 -0
  126. package/dist/internal/graphql.d.ts.map +1 -0
  127. package/dist/internal/graphql.js +195 -0
  128. package/dist/internal/graphql.js.map +1 -0
  129. package/dist/internal/graphqlHeaders.d.ts +4 -0
  130. package/dist/internal/graphqlHeaders.d.ts.map +1 -0
  131. package/dist/internal/graphqlHeaders.js +11 -0
  132. package/dist/internal/graphqlHeaders.js.map +1 -0
  133. package/dist/internal/request.js +20 -1
  134. package/dist/internal/request.js.map +1 -1
  135. package/dist/internal/schema/toCodeDocument.js +4 -1
  136. package/dist/internal/schema/toCodeDocument.js.map +1 -1
  137. package/dist/internal/schema/toJsonSchemaDocument.js +29 -5
  138. package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
  139. package/dist/internal/version.js +1 -1
  140. package/dist/net/Host.d.ts +49 -0
  141. package/dist/net/Host.d.ts.map +1 -1
  142. package/dist/net/Host.js +55 -0
  143. package/dist/net/Host.js.map +1 -1
  144. package/dist/net/NetAddress.d.ts +8 -0
  145. package/dist/net/NetAddress.d.ts.map +1 -1
  146. package/dist/net/NetAddress.js +8 -0
  147. package/dist/net/NetAddress.js.map +1 -1
  148. package/dist/rpc/RpcServer.d.ts.map +1 -1
  149. package/dist/rpc/RpcServer.js +36 -9
  150. package/dist/rpc/RpcServer.js.map +1 -1
  151. package/dist/socket/Socket.d.ts +6 -0
  152. package/dist/socket/Socket.d.ts.map +1 -1
  153. package/dist/socket/Socket.js.map +1 -1
  154. package/dist/workflow/DurableDeferred.d.ts.map +1 -1
  155. package/dist/workflow/DurableDeferred.js +32 -3
  156. package/dist/workflow/DurableDeferred.js.map +1 -1
  157. package/dist/workflow/WorkflowEngine.d.ts +24 -2
  158. package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
  159. package/dist/workflow/WorkflowEngine.js +11 -2
  160. package/dist/workflow/WorkflowEngine.js.map +1 -1
  161. package/package.json +6 -3
  162. package/src/Context.ts +9 -0
  163. package/src/RequestResolver.ts +4 -10
  164. package/src/Scheduler.ts +9 -0
  165. package/src/Schema.ts +8 -0
  166. package/src/SchemaGetter.ts +47 -35
  167. package/src/Sink.ts +45 -18
  168. package/src/Stream.ts +33 -4
  169. package/src/Utils.ts +8 -5
  170. package/src/ai/AnthropicStructuredOutput.ts +2 -2
  171. package/src/ai/Chat.ts +2 -2
  172. package/src/ai/LanguageModel.ts +96 -24
  173. package/src/ai/McpServer.ts +244 -90
  174. package/src/ai/Prompt.ts +24 -10
  175. package/src/ai/Response.ts +6 -3
  176. package/src/cluster/ClusterWorkflowEngine.ts +51 -12
  177. package/src/cluster/Sharding.ts +12 -9
  178. package/src/encoding/Sse.ts +69 -79
  179. package/src/graphql/GraphQL.ts +494 -0
  180. package/src/graphql/GraphQLClient.ts +912 -0
  181. package/src/graphql/GraphQLClientError.ts +542 -0
  182. package/src/graphql/GraphQLGroup.ts +167 -0
  183. package/src/graphql/GraphQLMiddleware.ts +253 -0
  184. package/src/graphql/GraphQLProtocol.ts +1286 -0
  185. package/src/graphql/GraphQLResolver.ts +1010 -0
  186. package/src/graphql/index.ts +48 -0
  187. package/src/http/HttpClient.ts +54 -10
  188. package/src/http/HttpEffect.ts +11 -5
  189. package/src/http/HttpMiddleware.ts +33 -34
  190. package/src/http/HttpRouter.ts +35 -0
  191. package/src/http/HttpServerResponse.ts +28 -16
  192. package/src/http/Multipart.ts +17 -1
  193. package/src/http-api/HttpApiScalar.ts +5 -0
  194. package/src/internal/dateTime.ts +13 -10
  195. package/src/internal/effect.ts +8 -3
  196. package/src/internal/graphql.ts +263 -0
  197. package/src/internal/graphqlHeaders.ts +11 -0
  198. package/src/internal/request.ts +31 -3
  199. package/src/internal/schema/toCodeDocument.ts +7 -1
  200. package/src/internal/schema/toJsonSchemaDocument.ts +34 -2
  201. package/src/internal/version.ts +1 -1
  202. package/src/net/Host.ts +72 -0
  203. package/src/net/NetAddress.ts +9 -0
  204. package/src/rpc/RpcServer.ts +55 -15
  205. package/src/socket/Socket.ts +6 -0
  206. package/src/workflow/DurableDeferred.ts +43 -5
  207. package/src/workflow/WorkflowEngine.ts +48 -4
@@ -0,0 +1,498 @@
1
+ /**
2
+ * A typed client with one method per operation in a `GraphQLGroup`. Queries
3
+ * and mutations return an `Effect`; subscriptions return a `Stream`. The
4
+ * client encodes variables, runs middleware, calls the `GraphQLProtocol` in
5
+ * context and decodes results.
6
+ *
7
+ * Retryable subscription failures restart the middleware chain on the
8
+ * `subscriptionRetry` schedule. {@link pages} and {@link items} provide
9
+ * cursor pagination. {@link makeTest} builds a mock client for tests, and
10
+ * {@link layerTest} provides it as a service layer. See `GraphQLProtocol`
11
+ * for transport options.
12
+ *
13
+ * @stability experimental
14
+ * @since 4.0.0
15
+ */
16
+ import * as Cause from "../Cause.js";
17
+ import * as Context from "../Context.js";
18
+ import * as Duration from "../Duration.js";
19
+ import * as Effect from "../Effect.js";
20
+ import { identity } from "../Function.js";
21
+ import * as Headers from "../http/Headers.js";
22
+ import * as UrlParams from "../http/UrlParams.js";
23
+ import * as internalGraphQL from "../internal/graphql.js";
24
+ import { getStackTraceLimit, setStackTraceLimit } from "../internal/stackTraceLimit.js";
25
+ import * as Layer from "../Layer.js";
26
+ import * as Option from "../Option.js";
27
+ import * as Schedule from "../Schedule.js";
28
+ import * as Schema from "../Schema.js";
29
+ import * as Stream from "../Stream.js";
30
+ import * as Struct from "../Struct.js";
31
+ import { DecodeError, GraphQLClientError, isGraphQLClientError, PaginationError } from "./GraphQLClientError.js";
32
+ import { ExecutionResult, GraphQLProtocol } from "./GraphQLProtocol.js";
33
+ /**
34
+ * The default subscription retry schedule: exponential from 500 milliseconds
35
+ * with factor 1.5, capped at 5 seconds, and never shorter than the server's
36
+ * `retryAfter`.
37
+ *
38
+ * @stability experimental
39
+ * @category constants
40
+ * @since 4.0.0
41
+ */
42
+ export const defaultSubscriptionRetry = /*#__PURE__*/Schedule.exponential("500 millis", 1.5).pipe(/*#__PURE__*/Schedule.setInputType(), /*#__PURE__*/Schedule.modifyDelay(({
43
+ duration,
44
+ input
45
+ }) => {
46
+ const capped = Duration.min(duration, Duration.seconds(5));
47
+ return Effect.succeed(input.retryAfter === undefined ? capped : Duration.max(capped, input.retryAfter));
48
+ }));
49
+ /**
50
+ * Builds a client from a group, requiring `GraphQLProtocol` and every
51
+ * middleware service attached to the group or its operations.
52
+ *
53
+ * **Details**
54
+ *
55
+ * Group middleware runs outside operation middleware. Within each level,
56
+ * middleware run in the order attached.
57
+ *
58
+ * `subscriptionRetry` decides how a subscription is retried after it fails
59
+ * with a retryable error: usually a `TransportError`, but also a
60
+ * `ResponseError` whose response carried a valid `Retry-After`, including an
61
+ * event with `errors` on a graphql-sse stream whose response had that header.
62
+ * It defaults to {@link defaultSubscriptionRetry}. Fatal errors are never
63
+ * retried, whatever the schedule. A retry starts a new subscription, so the
64
+ * server may send events again that the stream already emitted.
65
+ *
66
+ * **Example** (A client as a service)
67
+ *
68
+ * ```ts import.meta.vitest
69
+ * import { Context, Effect, Layer, Schema, Stream } from "effect"
70
+ * import { GraphQL, GraphQLClient, GraphQLGroup, GraphQLProtocol } from "effect/graphql"
71
+ *
72
+ * // What the generator emits for viewer.graphql
73
+ * const Viewer = GraphQL.query("Viewer", {
74
+ * document: "query Viewer{viewer{login}}",
75
+ * result: Schema.Struct({ viewer: Schema.Struct({ login: Schema.String }) })
76
+ * })
77
+ * const ViewerGraphQLGroup = GraphQLGroup.make(Viewer)
78
+ *
79
+ * class GitHub extends Context.Service<GitHub>()("app/GitHub", {
80
+ * make: GraphQLClient.make(ViewerGraphQLGroup)
81
+ * }) {}
82
+ *
83
+ * // A scripted transport; use GraphQLProtocol.layerHttp({ url }) for a real server
84
+ * const Scripted = Layer.succeed(GraphQLProtocol.GraphQLProtocol, {
85
+ * execute: () => Effect.succeed({ body: { data: { viewer: { login: "tim" } } } }),
86
+ * subscribe: () => Stream.empty
87
+ * })
88
+ *
89
+ * const program = GitHub.use((github) => github.Viewer()).pipe(
90
+ * Effect.provide(Layer.effect(GitHub, GitHub.make).pipe(Layer.provide(Scripted)))
91
+ * )
92
+ *
93
+ * await Effect.runPromise(program) // => { viewer: { login: "tim" } }
94
+ * ```
95
+ *
96
+ * **Example** (Partial results)
97
+ *
98
+ * ```ts import.meta.vitest
99
+ * import { Effect, Layer, Schema, Stream } from "effect"
100
+ * import { GraphQL, GraphQLClient, GraphQLGroup, GraphQLProtocol } from "effect/graphql"
101
+ *
102
+ * const Repos = GraphQL.query("Repos", {
103
+ * document: "query Repos{a:repository(owner:\"x\",name:\"a\"){name} b:repository(owner:\"x\",name:\"b\"){name}}",
104
+ * result: Schema.Struct({
105
+ * a: Schema.NullOr(Schema.Struct({ name: Schema.String })),
106
+ * b: Schema.NullOr(Schema.Struct({ name: Schema.String }))
107
+ * })
108
+ * })
109
+ *
110
+ * const Scripted = Layer.succeed(GraphQLProtocol.GraphQLProtocol, {
111
+ * execute: () =>
112
+ * Effect.succeed({
113
+ * body: {
114
+ * data: { a: { name: "a" }, b: null },
115
+ * errors: [{ message: "Could not resolve to a Repository", path: ["b"] }]
116
+ * }
117
+ * }),
118
+ * subscribe: () => Stream.empty
119
+ * })
120
+ *
121
+ * const program = Effect.gen(function*() {
122
+ * const client = yield* GraphQLClient.make(GraphQLGroup.make(Repos))
123
+ * // The default call fails with a ResponseError because `errors` is non-empty
124
+ * const failed = yield* Effect.flip(client.Repos())
125
+ * // With partial: true the decoded data comes back together with the errors
126
+ * const { data, errors } = yield* client.Repos(undefined, { partial: true })
127
+ * return [failed.reason._tag, data.a?.name, errors[0].path?.[0]]
128
+ * })
129
+ *
130
+ * await Effect.runPromise(program.pipe(Effect.provide(Scripted))) // => ["ResponseError", "a", "b"]
131
+ * ```
132
+ *
133
+ * @stability experimental
134
+ * @category constructors
135
+ * @since 4.0.0
136
+ */
137
+ export const make = (group, options) => Effect.gen(function* () {
138
+ const protocol = yield* GraphQLProtocol;
139
+ const context = yield* Effect.context();
140
+ const retryPolicy = retryableOnly(options?.subscriptionRetry ?? defaultSubscriptionRetry);
141
+ return fromGroup(group, operation => makeMethod(operation, middlewareChain(context, group, operation), protocol, retryPolicy));
142
+ });
143
+ // Type boundary: a mapping over the operations cannot prove the mapped type's
144
+ // name/kind relationship.
145
+ const fromGroup = (group, f) => Object.fromEntries(group.operations.map(operation => [operation.name, f(operation)]));
146
+ // Runtime tags erase middleware types; `make` requires all their identifiers.
147
+ const middlewareChain = (context, group, operation) => [...group.middlewares, ...operation.middlewares].map(tag => Context.getUnsafe(context, tag));
148
+ // Steps `schedule` only for retryable `GraphQLClientError`s. Middleware
149
+ // errors and fatal errors end the retries before reaching it, so a custom
150
+ // schedule can rely on its input being a `GraphQLClientError`.
151
+ const retryableOnly = schedule => Schedule.fromStep(Effect.map(Schedule.toStep(schedule), step => (now, input) => isGraphQLClientError(input) && input.isRetryable ? step(now, input) : Cause.done(undefined)));
152
+ // `status` and `headers` are transport metadata, never read from the body.
153
+ const decodeExecutionResult = /*#__PURE__*/Schema.decodeUnknownEffect(/*#__PURE__*/ExecutionResult.mapFields(/*#__PURE__*/Struct.omit(["status", "headers"])));
154
+ // Type boundary: a call without `context` has `R2 = never` unless the caller
155
+ // names `R2` explicitly, so an empty context stands in for `Context<R2>`.
156
+ const callContext = options => options?.context ?? Context.empty();
157
+ const makeMethod = (operation, chain, protocol, retryPolicy) => {
158
+ const {
159
+ decodePartial,
160
+ decodeStrict,
161
+ encodeVariables,
162
+ fail,
163
+ schemaFail
164
+ } = internalGraphQL.makeCodec(operation);
165
+ const notGraphQL = schemaFail(description => new DecodeError({
166
+ description: `Not a GraphQL response: ${description}`
167
+ }));
168
+ const buildRequest = (variables, options) => encodeVariables(variables).pipe(Effect.map(encoded => ({
169
+ kind: operation.kind,
170
+ query: operation.document,
171
+ operationName: operation.name,
172
+ variables: encoded,
173
+ headers: Headers.fromInput(options?.headers),
174
+ urlParams: options?.urlParams === undefined ? UrlParams.empty : UrlParams.fromInput(options.urlParams)
175
+ })));
176
+ const decodeResponse = ({
177
+ body,
178
+ ...metadata
179
+ }) => decodeExecutionResult(body).pipe(Effect.map(result => ({
180
+ ...result,
181
+ ...metadata
182
+ })), Effect.catch(notGraphQL));
183
+ // Type boundary: a middleware sees the errors of the middleware further in
184
+ // as `Types.unhandled` (as in `RpcMiddleware`), and none of their
185
+ // requirements. Those errors are part of `GraphQL.Error<Op>`, so the chain
186
+ // restates its type here. Force POST only at the transport boundary.
187
+ const execute = (index, request, forcePost) => index === chain.length ? protocol.execute(request).pipe(forcePost ? Effect.provideService(internalGraphQL.ForcePost, true) : identity, Effect.mapError(fail), Effect.flatMap(decodeResponse)) : chain[index].execute({
188
+ operation,
189
+ request,
190
+ next: request => execute(index + 1, request, forcePost)
191
+ });
192
+ const subscribe = (index, request) => index === chain.length ? protocol.subscribe(request).pipe(Stream.mapError(fail), Stream.mapEffect(decodeResponse)) : chain[index].subscribe({
193
+ operation,
194
+ request,
195
+ next: request => subscribe(index + 1, request)
196
+ });
197
+ if (operation.kind === "subscription") {
198
+ const subscriptionMethod = (...[variables, options]) => Stream.unwrap(Effect.map(buildRequest(variables, options), request => subscribe(0, request))).pipe(Stream.mapEffect(decodeStrict), Stream.retry(retryPolicy), Stream.provideContext(callContext(options)));
199
+ return Object.assign(subscriptionMethod, {
200
+ operation
201
+ });
202
+ }
203
+ function method(variables, options) {
204
+ return buildRequest(variables, options).pipe(Effect.flatMap(request => execute(0, request, false)), Effect.flatMap(result => options?.partial === true ? decodePartial(result) : decodeStrict(result)), Effect.provideContext(callContext(options)));
205
+ }
206
+ internalGraphQL.rawExecutors.set(method, request => execute(0, request, true));
207
+ return Object.assign(method, {
208
+ operation
209
+ });
210
+ };
211
+ /**
212
+ * Pages forward through a cursor connection, emitting one connection per
213
+ * page.
214
+ *
215
+ * **Details**
216
+ *
217
+ * Requires an optional string `$after` variable (see {@link PagingVariables}).
218
+ * The first request omits `after`; subsequent requests use the previous
219
+ * `endCursor`. Pages are fetched only when pulled, so `Stream.take` stops
220
+ * further requests. Middleware runs on each page.
221
+ *
222
+ * `connection` extracts the connection from each result. `options` is
223
+ * forwarded to every call but cannot include `partial`: errors fail the stream.
224
+ * Its `headers` accept `Headers.Input`, just as for operation calls.
225
+ *
226
+ * The stream ends after a page whose `hasNextPage` is `false`. A `null`
227
+ * connection on the first page gives an empty stream; on a later page it
228
+ * fails with a `PaginationError`, as does `hasNextPage: true` with a `null`
229
+ * or unchanged `endCursor`.
230
+ *
231
+ * Root fields that come with every page, such as GitHub's `rateLimit`, are for
232
+ * middleware to read from the raw `ExecutionResult`.
233
+ *
234
+ * **Example** (Paging issues, two per page)
235
+ *
236
+ * ```ts import.meta.vitest
237
+ * import { Effect, Layer, Schema, Stream } from "effect"
238
+ * import { GraphQL, GraphQLClient, GraphQLGroup, GraphQLProtocol } from "effect/graphql"
239
+ *
240
+ * const RepoIssues = GraphQL.query("RepoIssues", {
241
+ * document: "query RepoIssues($owner:String!,$name:String!,$after:String){repository(owner:$owner,name:$name){issues(first:2,after:$after){pageInfo{hasNextPage endCursor}nodes{number}}}}",
242
+ * variables: { owner: Schema.String, name: Schema.String, after: Schema.optional(Schema.NullOr(Schema.String)) },
243
+ * result: Schema.Struct({
244
+ * repository: Schema.NullOr(Schema.Struct({
245
+ * issues: Schema.Struct({
246
+ * pageInfo: Schema.Struct({ hasNextPage: Schema.Boolean, endCursor: Schema.NullOr(Schema.String) }),
247
+ * nodes: Schema.NullOr(Schema.Array(Schema.NullOr(Schema.Struct({ number: Schema.Int }))))
248
+ * })
249
+ * }))
250
+ * })
251
+ * })
252
+ *
253
+ * // A scripted server with two pages
254
+ * const Scripted = Layer.succeed(GraphQLProtocol.GraphQLProtocol, {
255
+ * execute: (request) => {
256
+ * const after = (request.variables as { after?: string }).after
257
+ * const page = after === undefined
258
+ * ? { pageInfo: { hasNextPage: true, endCursor: "c1" }, nodes: [{ number: 1 }, { number: 2 }] }
259
+ * : { pageInfo: { hasNextPage: false, endCursor: null }, nodes: [{ number: 3 }] }
260
+ * return Effect.succeed({ body: { data: { repository: { issues: page } } } })
261
+ * },
262
+ * subscribe: () => Stream.empty
263
+ * })
264
+ *
265
+ * const program = Effect.gen(function*() {
266
+ * const client = yield* GraphQLClient.make(GraphQLGroup.make(RepoIssues))
267
+ * const pages = GraphQLClient.pages(client.RepoIssues, {
268
+ * variables: { owner: "Effect-TS", name: "effect" },
269
+ * connection: (result) => result.repository?.issues
270
+ * })
271
+ * return yield* Stream.runCollect(Stream.map(pages, (page) => page.pageInfo.endCursor))
272
+ * })
273
+ *
274
+ * await Effect.runPromise(program.pipe(Effect.provide(Scripted))) // => ["c1", null]
275
+ * ```
276
+ *
277
+ * @stability experimental
278
+ * @category paging
279
+ * @since 4.0.0
280
+ */
281
+ export const pages = (method, options) => {
282
+ // Type boundary: `method`'s strict overload, with `variables` widened.
283
+ // `PagingVariables` has already checked that `options.variables` plus an
284
+ // optional string `after` are the operation's variables, but the overloads'
285
+ // conditional parameter types over a generic `Op` cannot carry that here.
286
+ const call = method;
287
+ // The state is the cursor to send; the first page is fetched without one.
288
+ return Stream.paginate(undefined, after => Effect.flatMap(call(after === undefined ? options.variables : {
289
+ ...options.variables,
290
+ after
291
+ }, options.options), result => {
292
+ const paginationError = description => Effect.fail(new GraphQLClientError({
293
+ operation: method.operation.name,
294
+ reason: new PaginationError({
295
+ description,
296
+ cursor: after ?? null
297
+ })
298
+ }));
299
+ const connection = options.connection(result);
300
+ if (connection === null || connection === undefined) {
301
+ return after === undefined ? Effect.succeed([[], Option.none()]) : paginationError("The connection was null on a page after the first");
302
+ }
303
+ const {
304
+ endCursor,
305
+ hasNextPage
306
+ } = connection.pageInfo;
307
+ if (!hasNextPage) return Effect.succeed([[connection], Option.none()]);
308
+ if (endCursor === null) return paginationError("hasNextPage is true but endCursor is null");
309
+ if (endCursor === after) return paginationError(`endCursor "${endCursor}" did not advance`);
310
+ return Effect.succeed([[connection], Option.some(endCursor)]);
311
+ }));
312
+ };
313
+ /**
314
+ * Like {@link pages}, but emits decoded entries from `nodes`, including
315
+ * `null` entries. Use `Stream.filter(Predicate.isNotNull)` to drop them.
316
+ * For connections selecting only `edges`, use {@link pages} with
317
+ * `Stream.flatMap`.
318
+ *
319
+ * **Example** (Flattening issue numbers across pages)
320
+ *
321
+ * ```ts import.meta.vitest
322
+ * import { Effect, Layer, Schema, Stream } from "effect"
323
+ * import { GraphQL, GraphQLClient, GraphQLGroup, GraphQLProtocol } from "effect/graphql"
324
+ *
325
+ * const RepoIssues = GraphQL.query("RepoIssues", {
326
+ * document: "query RepoIssues($owner:String!,$name:String!,$after:String){repository(owner:$owner,name:$name){issues(first:2,after:$after){pageInfo{hasNextPage endCursor}nodes{number}}}}",
327
+ * variables: { owner: Schema.String, name: Schema.String, after: Schema.optional(Schema.NullOr(Schema.String)) },
328
+ * result: Schema.Struct({
329
+ * repository: Schema.NullOr(Schema.Struct({
330
+ * issues: Schema.Struct({
331
+ * pageInfo: Schema.Struct({ hasNextPage: Schema.Boolean, endCursor: Schema.NullOr(Schema.String) }),
332
+ * nodes: Schema.NullOr(Schema.Array(Schema.NullOr(Schema.Struct({ number: Schema.Int }))))
333
+ * })
334
+ * }))
335
+ * })
336
+ * })
337
+ *
338
+ * const Scripted = Layer.succeed(GraphQLProtocol.GraphQLProtocol, {
339
+ * execute: (request) => {
340
+ * const after = (request.variables as { after?: string }).after
341
+ * const page = after === undefined
342
+ * ? { pageInfo: { hasNextPage: true, endCursor: "c1" }, nodes: [{ number: 1 }, null] }
343
+ * : { pageInfo: { hasNextPage: false, endCursor: null }, nodes: [{ number: 3 }] }
344
+ * return Effect.succeed({ body: { data: { repository: { issues: page } } } })
345
+ * },
346
+ * subscribe: () => Stream.empty
347
+ * })
348
+ *
349
+ * const program = Effect.gen(function*() {
350
+ * const client = yield* GraphQLClient.make(GraphQLGroup.make(RepoIssues))
351
+ * const items = GraphQLClient.items(client.RepoIssues, {
352
+ * variables: { owner: "Effect-TS", name: "effect" },
353
+ * connection: (result) => result.repository?.issues
354
+ * })
355
+ * return yield* Stream.runCollect(Stream.map(items, (issue) => issue?.number ?? null))
356
+ * })
357
+ *
358
+ * await Effect.runPromise(program.pipe(Effect.provide(Scripted))) // => [1, null, 3]
359
+ * ```
360
+ *
361
+ * @stability experimental
362
+ * @category paging
363
+ * @since 4.0.0
364
+ */
365
+ export const items = (method, options) => Stream.flatMap(pages(method, options), connection => Stream.fromArray(connection.nodes ?? []));
366
+ /**
367
+ * Builds a client for tests that answers each operation from a handler,
368
+ * without a protocol.
369
+ *
370
+ * **Details**
371
+ *
372
+ * Handlers receive the caller's `variables` and options unchanged and return
373
+ * values in their decoded form. Nothing is encoded, decoded or validated, and
374
+ * no middleware runs. Called with `{ partial: true }`, a method returns
375
+ * `{ data, errors: [] }`. Subscriptions are not retried. Every method carries
376
+ * `.operation`, so {@link pages} and {@link items} work on it.
377
+ *
378
+ * Calling an operation without a handler dies with an `UnimplementedError`
379
+ * defect, so `catchTag` in the code under test cannot swallow a missing stub.
380
+ *
381
+ * Methods keep the real client's types, including middleware service
382
+ * requirements. Tests must provide those services even though mocks do not
383
+ * use them.
384
+ *
385
+ * To test partial data together with `errors`, or the encode and decode path,
386
+ * provide a scripted `GraphQLProtocol` layer to {@link make} instead.
387
+ *
388
+ * **Example** (Replacing a client service in tests)
389
+ *
390
+ * ```ts import.meta.vitest
391
+ * import { Context, Effect, Layer, Schema } from "effect"
392
+ * import { GraphQL, GraphQLClient, GraphQLGroup } from "effect/graphql"
393
+ *
394
+ * const RepoIssues = GraphQL.query("RepoIssues", {
395
+ * document: "query RepoIssues($owner:String!,$name:String!){repository(owner:$owner,name:$name){issues{totalCount}}}",
396
+ * variables: { owner: Schema.String, name: Schema.String },
397
+ * result: Schema.Struct({
398
+ * repository: Schema.NullOr(Schema.Struct({ issues: Schema.Struct({ totalCount: Schema.Int }) }))
399
+ * })
400
+ * })
401
+ * const GitHubGraphQLGroup = GraphQLGroup.make(RepoIssues)
402
+ *
403
+ * class GitHub extends Context.Service<GitHub>()("app/GitHub", {
404
+ * make: GraphQLClient.make(GitHubGraphQLGroup)
405
+ * }) {}
406
+ *
407
+ * const GitHubTest = Layer.succeed(
408
+ * GitHub,
409
+ * GraphQLClient.makeTest(GitHubGraphQLGroup)({
410
+ * RepoIssues: ({ name }) => Effect.succeed({ repository: { issues: { totalCount: name.length } } })
411
+ * })
412
+ * )
413
+ *
414
+ * const program = GitHub.use((github) => github.RepoIssues({ owner: "Effect-TS", name: "effect" }))
415
+ *
416
+ * await Effect.runPromise(program.pipe(Effect.provide(GitHubTest))) // => { repository: { issues: { totalCount: 6 } } }
417
+ * ```
418
+ *
419
+ * @stability experimental
420
+ * @category testing
421
+ * @since 4.0.0
422
+ */
423
+ export const makeTest = group => handlers => {
424
+ // Type boundary: the mapped type keys handlers by name, which a lookup by a
425
+ // runtime name cannot follow.
426
+ const byName = handlers;
427
+ return fromGroup(group, operation => makeTestMethod(operation, Object.hasOwn(byName, operation.name) ? byName[operation.name] : undefined));
428
+ };
429
+ /**
430
+ * Builds a mock layer for a client service using {@link makeTest}. Bind the
431
+ * service and group once to expose a `layerTest(handlers)` helper on the service.
432
+ * The group fixes the operation types before the handlers are checked.
433
+ *
434
+ * **Example** (Binding a mock layer to a client service)
435
+ *
436
+ * ```ts import.meta.vitest
437
+ * import { Context, Effect, Schema } from "effect"
438
+ * import { GraphQL, GraphQLClient, GraphQLGroup } from "effect/graphql"
439
+ *
440
+ * const RepoIssues = GraphQL.query("RepoIssues", {
441
+ * document: "query RepoIssues($owner:String!,$name:String!){repository(owner:$owner,name:$name){issues{totalCount}}}",
442
+ * variables: { owner: Schema.String, name: Schema.String },
443
+ * result: Schema.Struct({
444
+ * repository: Schema.NullOr(Schema.Struct({ issues: Schema.Struct({ totalCount: Schema.Int }) }))
445
+ * })
446
+ * })
447
+ * const GitHubGraphQLGroup = GraphQLGroup.make(RepoIssues)
448
+ *
449
+ * class GitHub extends Context.Service<GitHub>()("app/GitHub", {
450
+ * make: GraphQLClient.make(GitHubGraphQLGroup)
451
+ * }) {
452
+ * static readonly layerTest = GraphQLClient.layerTest(GitHub, GitHubGraphQLGroup)
453
+ * }
454
+ *
455
+ * const program = GitHub.use((github) => github.RepoIssues({ owner: "Effect-TS", name: "effect" }))
456
+ *
457
+ * await Effect.runPromise(program.pipe(Effect.provide(GitHub.layerTest({
458
+ * RepoIssues: ({ name }) => Effect.succeed({ repository: { issues: { totalCount: name.length } } })
459
+ * })))) // => { repository: { issues: { totalCount: 6 } } }
460
+ * ```
461
+ *
462
+ * @see {@link makeTest} for mock behavior and the middleware-services limitation.
463
+ * @stability experimental
464
+ * @category testing
465
+ * @since 4.0.0
466
+ */
467
+ export const layerTest = (service, group) => handlers =>
468
+ // The group constraint checks that the mock satisfies the service shape.
469
+ Layer.succeed(service, makeTest(group)(handlers));
470
+ const makeTestMethod = (operation, handler) => {
471
+ const subscription = operation.kind === "subscription";
472
+ if (handler === undefined) {
473
+ const unimplemented = () => {
474
+ const prevLimit = getStackTraceLimit();
475
+ setStackTraceLimit(2);
476
+ const error = new Error(`GraphQLClient: Unimplemented operation "${operation.name}"`);
477
+ setStackTraceLimit(prevLimit);
478
+ error.name = "UnimplementedError";
479
+ return subscription ? Stream.die(error) : Effect.die(error);
480
+ };
481
+ return Object.assign(unimplemented, {
482
+ operation
483
+ });
484
+ }
485
+ const call = (variables, options) => {
486
+ const run = () => handler(variables === undefined ? {} : variables, options ?? {});
487
+ if (subscription) return Stream.suspend(run);
488
+ const result = Effect.suspend(run);
489
+ return options?.partial === true ? Effect.map(result, data => ({
490
+ data,
491
+ errors: []
492
+ })) : result;
493
+ };
494
+ return Object.assign(call, {
495
+ operation
496
+ });
497
+ };
498
+ //# sourceMappingURL=GraphQLClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphQLClient.js","names":[],"sources":["../../src/graphql/GraphQLClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;AAeA,OAAO,KAAK,KAAK,MAAM,aAAa;AACpC,OAAO,KAAK,OAAO,MAAM,eAAe;AACxC,OAAO,KAAK,QAAQ,MAAM,gBAAgB;AAC1C,OAAO,KAAK,MAAM,MAAM,cAAc;AACtC,SAAS,QAAQ,QAAQ,gBAAgB;AACzC,OAAO,KAAK,OAAO,MAAM,oBAAoB;AAC7C,OAAO,KAAK,SAAS,MAAM,sBAAsB;AACjD,OAAO,KAAK,eAAe,MAAM,wBAAwB;AACzD,SAAS,kBAAkB,EAAE,kBAAkB,QAAQ,gCAAgC;AACvF,OAAO,KAAK,KAAK,MAAM,aAAa;AACpC,OAAO,KAAK,MAAM,MAAM,cAAc;AAEtC,OAAO,KAAK,QAAQ,MAAM,gBAAgB;AAC1C,OAAO,KAAK,MAAM,MAAM,cAAc;AACtC,OAAO,KAAK,MAAM,MAAM,cAAc;AACtC,OAAO,KAAK,MAAM,MAAM,cAAc;AAGtC,SACE,WAAW,EACX,kBAAkB,EAElB,oBAAoB,EACpB,eAAe,QACV,yBAAyB;AAGhC,SAAS,eAAe,EAAE,eAAe,QAA6B,sBAAsB;AAyH5F;;;;;;;;;AASA,OAAO,MAAM,wBAAwB,gBAA6D,QAAQ,CAAC,WAAW,CACpH,YAAY,EACZ,GAAG,CACJ,CAAC,IAAI,cACJ,QAAQ,CAAC,YAAY,EAAsB,eAC3C,QAAQ,CAAC,WAAW,CAAC,CAAC;EAAE,QAAQ;EAAE;AAAK,CAAE,KAAI;EAC3C,MAAM,MAAM,GAAG,QAAQ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