Skip to content

Commit 39736ef

Browse files
committed
improve graphql initial funcs
1 parent f713430 commit 39736ef

24 files changed

Lines changed: 373 additions & 2936 deletions

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,6 @@ api.Response.text("Created")
171171
.withCors("*");
172172
```
173173

174-
Run an example:
175-
176-
```bash
177-
zig build run
178-
```
179-
180174
## 🧪 Testing
181175

182176
Run the test suite:

examples/graphql.zig

Lines changed: 97 additions & 143 deletions
Large diffs are not rendered by default.

src/app.zig

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ pub const RunConfig = struct {
6868
access_log: bool = true,
6969
num_threads: ?u8 = null,
7070
auto_port: bool = true,
71+
disable_reserved_routes: bool = false,
7172
};
7273

7374
/// Main application type.
@@ -255,6 +256,7 @@ pub const App = struct {
255256
.enable_access_log = config.access_log,
256257
.num_threads = thread_count,
257258
.auto_port = config.auto_port,
259+
.disable_reserved_routes = config.disable_reserved_routes,
258260
});
259261
defer server.deinit();
260262

@@ -275,7 +277,6 @@ pub const App = struct {
275277
self.router.error_handler = handler;
276278
}
277279

278-
279280
/// Configures GraphQL support with the provided schema using comptime paths.
280281
/// Use this for static GraphQL configuration at compile time.
281282
pub fn enableGraphQLComptime(
@@ -383,7 +384,7 @@ pub const App = struct {
383384
.setStatus(.no_content)
384385
.setHeader("Access-Control-Allow-Origin", "*")
385386
.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
386-
.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization")
387+
.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, Accept, Origin, X-Requested-With, apollo-require-preflight")
387388
.setHeader("Access-Control-Max-Age", "86400");
388389
}
389390

@@ -555,7 +556,6 @@ pub const App = struct {
555556
return self.graphql_schema;
556557
}
557558

558-
559559
/// Configures WebSocket support.
560560
pub fn enableWebSocket(self: *App, config: websocket.WebSocketConfig) !void {
561561
self.ws_hub = try self.allocator.create(websocket.Hub);
@@ -574,7 +574,6 @@ pub const App = struct {
574574
return self.ws_hub;
575575
}
576576

577-
578577
/// Configures metrics collection and export.
579578
pub fn enableMetrics(self: *App, config: metrics.RegistryConfig) !void {
580579
self.metrics_registry = try self.allocator.create(metrics.Registry);
@@ -598,7 +597,6 @@ pub const App = struct {
598597
return self.metrics_registry;
599598
}
600599

601-
602600
/// Configures health check endpoints.
603601
pub fn enableHealthChecks(self: *App, config: metrics.HealthChecker.HealthConfig) !void {
604602
self.health_checker = try self.allocator.create(metrics.HealthChecker);
@@ -625,7 +623,6 @@ pub const App = struct {
625623
}
626624
}
627625

628-
629626
/// Configures response caching.
630627
pub fn enableCaching(self: *App, config: cache.ResponseCache.ResponseCacheConfig) !void {
631628
self.response_cache = try self.allocator.create(cache.ResponseCache);
@@ -638,7 +635,6 @@ pub const App = struct {
638635
return self.response_cache;
639636
}
640637

641-
642638
/// Configures session management.
643639
pub fn enableSessions(self: *App, config: session.SessionConfig) !void {
644640
const store = try self.allocator.create(session.MemoryStore);

src/assets/altair-main.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/assets/altair-polyfills.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/assets/altair-runtime.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/assets/altair-styles.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/assets/apollo-sandbox.min.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)