@effect-gql/core 0.1.0 → 1.1.0

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 (164) hide show
  1. package/README.md +100 -0
  2. package/builder/index.cjs +1446 -0
  3. package/builder/index.cjs.map +1 -0
  4. package/builder/index.d.cts +260 -0
  5. package/{dist/builder/pipe-api.d.ts → builder/index.d.ts} +50 -21
  6. package/builder/index.js +1405 -0
  7. package/builder/index.js.map +1 -0
  8. package/index.cjs +3469 -0
  9. package/index.cjs.map +1 -0
  10. package/index.d.cts +529 -0
  11. package/index.d.ts +529 -0
  12. package/index.js +3292 -0
  13. package/index.js.map +1 -0
  14. package/package.json +19 -28
  15. package/schema-builder-DKvkzU_M.d.cts +965 -0
  16. package/schema-builder-DKvkzU_M.d.ts +965 -0
  17. package/server/index.cjs +1579 -0
  18. package/server/index.cjs.map +1 -0
  19. package/server/index.d.cts +682 -0
  20. package/server/index.d.ts +682 -0
  21. package/server/index.js +1548 -0
  22. package/server/index.js.map +1 -0
  23. package/dist/analyzer-extension.d.ts +0 -105
  24. package/dist/analyzer-extension.d.ts.map +0 -1
  25. package/dist/analyzer-extension.js +0 -137
  26. package/dist/analyzer-extension.js.map +0 -1
  27. package/dist/builder/execute.d.ts +0 -26
  28. package/dist/builder/execute.d.ts.map +0 -1
  29. package/dist/builder/execute.js +0 -104
  30. package/dist/builder/execute.js.map +0 -1
  31. package/dist/builder/field-builders.d.ts +0 -30
  32. package/dist/builder/field-builders.d.ts.map +0 -1
  33. package/dist/builder/field-builders.js +0 -200
  34. package/dist/builder/field-builders.js.map +0 -1
  35. package/dist/builder/index.d.ts +0 -7
  36. package/dist/builder/index.d.ts.map +0 -1
  37. package/dist/builder/index.js +0 -31
  38. package/dist/builder/index.js.map +0 -1
  39. package/dist/builder/pipe-api.d.ts.map +0 -1
  40. package/dist/builder/pipe-api.js +0 -151
  41. package/dist/builder/pipe-api.js.map +0 -1
  42. package/dist/builder/schema-builder.d.ts +0 -301
  43. package/dist/builder/schema-builder.d.ts.map +0 -1
  44. package/dist/builder/schema-builder.js +0 -566
  45. package/dist/builder/schema-builder.js.map +0 -1
  46. package/dist/builder/type-registry.d.ts +0 -80
  47. package/dist/builder/type-registry.d.ts.map +0 -1
  48. package/dist/builder/type-registry.js +0 -505
  49. package/dist/builder/type-registry.js.map +0 -1
  50. package/dist/builder/types.d.ts +0 -283
  51. package/dist/builder/types.d.ts.map +0 -1
  52. package/dist/builder/types.js +0 -3
  53. package/dist/builder/types.js.map +0 -1
  54. package/dist/cli/generate-schema.d.ts +0 -29
  55. package/dist/cli/generate-schema.d.ts.map +0 -1
  56. package/dist/cli/generate-schema.js +0 -233
  57. package/dist/cli/generate-schema.js.map +0 -1
  58. package/dist/cli/index.d.ts +0 -19
  59. package/dist/cli/index.d.ts.map +0 -1
  60. package/dist/cli/index.js +0 -24
  61. package/dist/cli/index.js.map +0 -1
  62. package/dist/context.d.ts +0 -18
  63. package/dist/context.d.ts.map +0 -1
  64. package/dist/context.js +0 -11
  65. package/dist/context.js.map +0 -1
  66. package/dist/error.d.ts +0 -45
  67. package/dist/error.d.ts.map +0 -1
  68. package/dist/error.js +0 -29
  69. package/dist/error.js.map +0 -1
  70. package/dist/extensions.d.ts +0 -130
  71. package/dist/extensions.d.ts.map +0 -1
  72. package/dist/extensions.js +0 -78
  73. package/dist/extensions.js.map +0 -1
  74. package/dist/index.d.ts +0 -12
  75. package/dist/index.d.ts.map +0 -1
  76. package/dist/index.js +0 -47
  77. package/dist/index.js.map +0 -1
  78. package/dist/loader.d.ts +0 -169
  79. package/dist/loader.d.ts.map +0 -1
  80. package/dist/loader.js +0 -237
  81. package/dist/loader.js.map +0 -1
  82. package/dist/resolver-context.d.ts +0 -154
  83. package/dist/resolver-context.d.ts.map +0 -1
  84. package/dist/resolver-context.js +0 -184
  85. package/dist/resolver-context.js.map +0 -1
  86. package/dist/schema-mapping.d.ts +0 -30
  87. package/dist/schema-mapping.d.ts.map +0 -1
  88. package/dist/schema-mapping.js +0 -280
  89. package/dist/schema-mapping.js.map +0 -1
  90. package/dist/server/cache-control.d.ts +0 -96
  91. package/dist/server/cache-control.d.ts.map +0 -1
  92. package/dist/server/cache-control.js +0 -308
  93. package/dist/server/cache-control.js.map +0 -1
  94. package/dist/server/complexity.d.ts +0 -165
  95. package/dist/server/complexity.d.ts.map +0 -1
  96. package/dist/server/complexity.js +0 -433
  97. package/dist/server/complexity.js.map +0 -1
  98. package/dist/server/config.d.ts +0 -66
  99. package/dist/server/config.d.ts.map +0 -1
  100. package/dist/server/config.js +0 -104
  101. package/dist/server/config.js.map +0 -1
  102. package/dist/server/graphiql.d.ts +0 -5
  103. package/dist/server/graphiql.d.ts.map +0 -1
  104. package/dist/server/graphiql.js +0 -43
  105. package/dist/server/graphiql.js.map +0 -1
  106. package/dist/server/index.d.ts +0 -18
  107. package/dist/server/index.d.ts.map +0 -1
  108. package/dist/server/index.js +0 -48
  109. package/dist/server/index.js.map +0 -1
  110. package/dist/server/router.d.ts +0 -79
  111. package/dist/server/router.d.ts.map +0 -1
  112. package/dist/server/router.js +0 -232
  113. package/dist/server/router.js.map +0 -1
  114. package/dist/server/schema-builder-extensions.d.ts +0 -42
  115. package/dist/server/schema-builder-extensions.d.ts.map +0 -1
  116. package/dist/server/schema-builder-extensions.js +0 -48
  117. package/dist/server/schema-builder-extensions.js.map +0 -1
  118. package/dist/server/sse-adapter.d.ts +0 -64
  119. package/dist/server/sse-adapter.d.ts.map +0 -1
  120. package/dist/server/sse-adapter.js +0 -227
  121. package/dist/server/sse-adapter.js.map +0 -1
  122. package/dist/server/sse-types.d.ts +0 -192
  123. package/dist/server/sse-types.d.ts.map +0 -1
  124. package/dist/server/sse-types.js +0 -63
  125. package/dist/server/sse-types.js.map +0 -1
  126. package/dist/server/ws-adapter.d.ts +0 -39
  127. package/dist/server/ws-adapter.d.ts.map +0 -1
  128. package/dist/server/ws-adapter.js +0 -247
  129. package/dist/server/ws-adapter.js.map +0 -1
  130. package/dist/server/ws-types.d.ts +0 -169
  131. package/dist/server/ws-types.d.ts.map +0 -1
  132. package/dist/server/ws-types.js +0 -11
  133. package/dist/server/ws-types.js.map +0 -1
  134. package/dist/server/ws-utils.d.ts +0 -42
  135. package/dist/server/ws-utils.d.ts.map +0 -1
  136. package/dist/server/ws-utils.js +0 -99
  137. package/dist/server/ws-utils.js.map +0 -1
  138. package/src/analyzer-extension.ts +0 -254
  139. package/src/builder/execute.ts +0 -153
  140. package/src/builder/field-builders.ts +0 -322
  141. package/src/builder/index.ts +0 -48
  142. package/src/builder/pipe-api.ts +0 -312
  143. package/src/builder/schema-builder.ts +0 -970
  144. package/src/builder/type-registry.ts +0 -670
  145. package/src/builder/types.ts +0 -305
  146. package/src/context.ts +0 -23
  147. package/src/error.ts +0 -32
  148. package/src/extensions.ts +0 -240
  149. package/src/index.ts +0 -32
  150. package/src/loader.ts +0 -363
  151. package/src/resolver-context.ts +0 -253
  152. package/src/schema-mapping.ts +0 -307
  153. package/src/server/cache-control.ts +0 -590
  154. package/src/server/complexity.ts +0 -774
  155. package/src/server/config.ts +0 -174
  156. package/src/server/graphiql.ts +0 -38
  157. package/src/server/index.ts +0 -96
  158. package/src/server/router.ts +0 -432
  159. package/src/server/schema-builder-extensions.ts +0 -51
  160. package/src/server/sse-adapter.ts +0 -327
  161. package/src/server/sse-types.ts +0 -234
  162. package/src/server/ws-adapter.ts +0 -355
  163. package/src/server/ws-types.ts +0 -192
  164. package/src/server/ws-utils.ts +0 -136
@@ -1,174 +0,0 @@
1
- import { Config, Option } from "effect"
2
- import type { ComplexityConfig } from "./complexity"
3
- import type { CacheControlConfig } from "./cache-control"
4
-
5
- /**
6
- * Configuration for the GraphiQL UI
7
- */
8
- export interface GraphiQLConfig {
9
- /** Path where GraphiQL UI is served (default: "/graphiql") */
10
- readonly path: string
11
- /** URL where GraphiQL sends requests (default: same as graphql path) */
12
- readonly endpoint: string
13
- }
14
-
15
- /**
16
- * Configuration for the GraphQL router
17
- */
18
- export interface GraphQLRouterConfig {
19
- /** Path for GraphQL endpoint (default: "/graphql") */
20
- readonly path: string
21
- /** GraphiQL configuration, or false to disable */
22
- readonly graphiql: false | GraphiQLConfig
23
- /** Query complexity limiting configuration */
24
- readonly complexity?: ComplexityConfig
25
- /** Enable introspection queries (default: true). Set to false in production. */
26
- readonly introspection: boolean
27
- /** Cache control configuration for HTTP Cache-Control headers */
28
- readonly cacheControl?: CacheControlConfig
29
- }
30
-
31
- /**
32
- * Default configuration values
33
- */
34
- export const defaultConfig: GraphQLRouterConfig = {
35
- path: "/graphql",
36
- graphiql: false,
37
- complexity: undefined,
38
- introspection: true,
39
- cacheControl: undefined,
40
- }
41
-
42
- /**
43
- * Normalize user-provided config (which may use boolean shorthand for graphiql)
44
- * into the full GraphQLRouterConfig format
45
- */
46
- export interface GraphQLRouterConfigInput {
47
- readonly path?: string
48
- readonly graphiql?: boolean | Partial<GraphiQLConfig>
49
- /** Query complexity limiting configuration */
50
- readonly complexity?: ComplexityConfig
51
- /** Enable introspection queries (default: true). Set to false in production. */
52
- readonly introspection?: boolean
53
- /** Cache control configuration for HTTP Cache-Control headers */
54
- readonly cacheControl?: CacheControlConfig
55
- }
56
-
57
- export const normalizeConfig = (input: GraphQLRouterConfigInput = {}): GraphQLRouterConfig => {
58
- const path = input.path ?? defaultConfig.path
59
-
60
- let graphiql: false | GraphiQLConfig = false
61
- if (input.graphiql === true) {
62
- graphiql = { path: "/graphiql", endpoint: path }
63
- } else if (input.graphiql && typeof input.graphiql === "object") {
64
- graphiql = {
65
- path: input.graphiql.path ?? "/graphiql",
66
- endpoint: input.graphiql.endpoint ?? path,
67
- }
68
- }
69
-
70
- return {
71
- path,
72
- graphiql,
73
- complexity: input.complexity,
74
- introspection: input.introspection ?? true,
75
- cacheControl: input.cacheControl,
76
- }
77
- }
78
-
79
- /**
80
- * Effect Config for loading GraphQL router configuration from environment variables.
81
- *
82
- * Environment variables:
83
- * - GRAPHQL_PATH: Path for GraphQL endpoint (default: "/graphql")
84
- * - GRAPHQL_INTROSPECTION: Enable introspection queries (default: true)
85
- * - GRAPHIQL_ENABLED: Enable GraphiQL UI (default: false)
86
- * - GRAPHIQL_PATH: Path for GraphiQL UI (default: "/graphiql")
87
- * - GRAPHIQL_ENDPOINT: URL where GraphiQL sends requests (default: same as GRAPHQL_PATH)
88
- * - GRAPHQL_MAX_DEPTH: Maximum query depth (optional)
89
- * - GRAPHQL_MAX_COMPLEXITY: Maximum complexity score (optional)
90
- * - GRAPHQL_MAX_ALIASES: Maximum number of aliases (optional)
91
- * - GRAPHQL_MAX_FIELDS: Maximum number of fields (optional)
92
- * - GRAPHQL_DEFAULT_FIELD_COMPLEXITY: Default field complexity (default: 1)
93
- * - GRAPHQL_CACHE_CONTROL_ENABLED: Enable cache control headers (default: false)
94
- * - GRAPHQL_CACHE_CONTROL_DEFAULT_MAX_AGE: Default maxAge for root fields (default: 0)
95
- * - GRAPHQL_CACHE_CONTROL_DEFAULT_SCOPE: Default scope - PUBLIC or PRIVATE (default: PUBLIC)
96
- */
97
- export const GraphQLRouterConfigFromEnv: Config.Config<GraphQLRouterConfig> = Config.all({
98
- path: Config.string("GRAPHQL_PATH").pipe(Config.withDefault("/graphql")),
99
- introspection: Config.boolean("GRAPHQL_INTROSPECTION").pipe(Config.withDefault(true)),
100
- graphiqlEnabled: Config.boolean("GRAPHIQL_ENABLED").pipe(Config.withDefault(false)),
101
- graphiqlPath: Config.string("GRAPHIQL_PATH").pipe(Config.withDefault("/graphiql")),
102
- graphiqlEndpoint: Config.string("GRAPHIQL_ENDPOINT").pipe(Config.option),
103
- maxDepth: Config.number("GRAPHQL_MAX_DEPTH").pipe(Config.option),
104
- maxComplexity: Config.number("GRAPHQL_MAX_COMPLEXITY").pipe(Config.option),
105
- maxAliases: Config.number("GRAPHQL_MAX_ALIASES").pipe(Config.option),
106
- maxFields: Config.number("GRAPHQL_MAX_FIELDS").pipe(Config.option),
107
- defaultFieldComplexity: Config.number("GRAPHQL_DEFAULT_FIELD_COMPLEXITY").pipe(
108
- Config.withDefault(1)
109
- ),
110
- cacheControlEnabled: Config.boolean("GRAPHQL_CACHE_CONTROL_ENABLED").pipe(
111
- Config.withDefault(false)
112
- ),
113
- cacheControlDefaultMaxAge: Config.number("GRAPHQL_CACHE_CONTROL_DEFAULT_MAX_AGE").pipe(
114
- Config.withDefault(0)
115
- ),
116
- cacheControlDefaultScope: Config.string("GRAPHQL_CACHE_CONTROL_DEFAULT_SCOPE").pipe(
117
- Config.withDefault("PUBLIC")
118
- ),
119
- }).pipe(
120
- Config.map(
121
- ({
122
- path,
123
- introspection,
124
- graphiqlEnabled,
125
- graphiqlPath,
126
- graphiqlEndpoint,
127
- maxDepth,
128
- maxComplexity,
129
- maxAliases,
130
- maxFields,
131
- defaultFieldComplexity,
132
- cacheControlEnabled,
133
- cacheControlDefaultMaxAge,
134
- cacheControlDefaultScope,
135
- }) => {
136
- // Check if any complexity option is set
137
- const hasComplexity =
138
- Option.isSome(maxDepth) ||
139
- Option.isSome(maxComplexity) ||
140
- Option.isSome(maxAliases) ||
141
- Option.isSome(maxFields)
142
-
143
- return {
144
- path,
145
- introspection,
146
- graphiql: graphiqlEnabled
147
- ? {
148
- path: graphiqlPath,
149
- endpoint: Option.isSome(graphiqlEndpoint) ? graphiqlEndpoint.value : path,
150
- }
151
- : (false as const),
152
- complexity: hasComplexity
153
- ? {
154
- maxDepth: Option.getOrUndefined(maxDepth),
155
- maxComplexity: Option.getOrUndefined(maxComplexity),
156
- maxAliases: Option.getOrUndefined(maxAliases),
157
- maxFields: Option.getOrUndefined(maxFields),
158
- defaultFieldComplexity,
159
- }
160
- : undefined,
161
- cacheControl: cacheControlEnabled
162
- ? {
163
- enabled: true,
164
- defaultMaxAge: cacheControlDefaultMaxAge,
165
- defaultScope: (cacheControlDefaultScope === "PRIVATE"
166
- ? "PRIVATE"
167
- : "PUBLIC") as import("../builder/types").CacheControlScope,
168
- calculateHttpHeaders: true,
169
- }
170
- : undefined,
171
- }
172
- }
173
- )
174
- )
@@ -1,38 +0,0 @@
1
- /**
2
- * Generate HTML for GraphiQL IDE, loading dependencies from CDN
3
- */
4
- export const graphiqlHtml = (endpoint: string): string => `<!DOCTYPE html>
5
- <html lang="en">
6
- <head>
7
- <meta charset="utf-8" />
8
- <meta name="viewport" content="width=device-width, initial-scale=1" />
9
- <title>GraphiQL</title>
10
- <link
11
- rel="stylesheet"
12
- href="https://unpkg.com/graphiql@3/graphiql.min.css"
13
- />
14
- </head>
15
- <body style="margin: 0; overflow: hidden;">
16
- <div id="graphiql" style="height: 100vh;"></div>
17
- <script
18
- crossorigin
19
- src="https://unpkg.com/react@18/umd/react.production.min.js"
20
- ></script>
21
- <script
22
- crossorigin
23
- src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"
24
- ></script>
25
- <script
26
- crossorigin
27
- src="https://unpkg.com/graphiql@3/graphiql.min.js"
28
- ></script>
29
- <script>
30
- const fetcher = GraphiQL.createFetcher({
31
- url: ${JSON.stringify(endpoint)},
32
- });
33
- ReactDOM.createRoot(document.getElementById('graphiql')).render(
34
- React.createElement(GraphiQL, { fetcher })
35
- );
36
- </script>
37
- </body>
38
- </html>`
@@ -1,96 +0,0 @@
1
- // Configuration types and utilities
2
- export type { GraphiQLConfig, GraphQLRouterConfig, GraphQLRouterConfigInput } from "./config"
3
-
4
- export { defaultConfig, normalizeConfig, GraphQLRouterConfigFromEnv } from "./config"
5
-
6
- // GraphiQL HTML generator
7
- export { graphiqlHtml } from "./graphiql"
8
-
9
- // Router factory
10
- export {
11
- makeGraphQLRouter,
12
- defaultErrorHandler,
13
- type MakeGraphQLRouterOptions,
14
- type ErrorHandler,
15
- } from "./router"
16
-
17
- // Schema builder extension
18
- export { toRouter } from "./schema-builder-extensions"
19
-
20
- // Complexity limiting
21
- export type {
22
- ComplexityConfig,
23
- ComplexityResult,
24
- ComplexityAnalysisInfo,
25
- ComplexityExceededInfo,
26
- ComplexityCalculator,
27
- FieldComplexity,
28
- FieldComplexityMap,
29
- } from "./complexity"
30
-
31
- export {
32
- ComplexityLimitExceededError,
33
- ComplexityAnalysisError,
34
- validateComplexity,
35
- defaultComplexityCalculator,
36
- depthOnlyCalculator,
37
- combineCalculators,
38
- ComplexityConfigFromEnv,
39
- } from "./complexity"
40
-
41
- // Cache control
42
- export type {
43
- CacheHintMap,
44
- CachePolicy,
45
- CacheControlConfig,
46
- CachePolicyAnalysisInfo,
47
- } from "./cache-control"
48
-
49
- export {
50
- computeCachePolicy,
51
- computeCachePolicyFromQuery,
52
- toCacheControlHeader,
53
- CacheControlConfigFromEnv,
54
- } from "./cache-control"
55
-
56
- // WebSocket subscription support
57
- export type {
58
- EffectWebSocket,
59
- CloseEvent,
60
- ConnectionContext,
61
- GraphQLWSOptions,
62
- GraphQLWSConfig,
63
- SubscribeMessage,
64
- CompleteMessage,
65
- } from "./ws-types"
66
-
67
- export { WebSocketError } from "./ws-types"
68
-
69
- export { makeGraphQLWSHandler } from "./ws-adapter"
70
-
71
- // WebSocket utilities for 'ws' library integration
72
- export type { WsWebSocket } from "./ws-utils"
73
- export { toEffectWebSocketFromWs, WS_CLOSED } from "./ws-utils"
74
-
75
- // SSE (Server-Sent Events) subscription support
76
- export type {
77
- EffectSSE,
78
- SSEEvent,
79
- SSEEventType,
80
- SSESubscriptionRequest,
81
- SSEConnectionContext,
82
- GraphQLSSEOptions,
83
- GraphQLSSEConfig,
84
- SSESubscriptionResult,
85
- } from "./sse-types"
86
-
87
- export {
88
- SSEError,
89
- SSE_HEADERS,
90
- formatNextEvent,
91
- formatErrorEvent,
92
- formatCompleteEvent,
93
- formatSSEMessage,
94
- } from "./sse-types"
95
-
96
- export { makeSSESubscriptionStream, makeGraphQLSSEHandler } from "./sse-adapter"