Skip to content

Commit dd030a5

Browse files
committed
⬆️ improvement: more cohesive yoga call typing
1 parent e30d153 commit dd030a5

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

lib/rumble.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { createYoga } from "graphql-yoga";
1+
import {
2+
type YogaServerOptions,
3+
createYoga as nativeCreateYoga,
4+
} from "graphql-yoga";
25
import { createAbilityBuilder } from "./abilityBuilder";
36
import { createContextFunction } from "./context";
47
import { createObjectImplementer } from "./object";
@@ -88,9 +91,13 @@ export const rumble = <
8891
makePubSubInstance,
8992
});
9093

91-
const yoga = () =>
92-
createYoga<RequestEvent>({
93-
...rumbleInput.nativeServerOptions,
94+
const createYoga = (
95+
args:
96+
| Omit<YogaServerOptions<RequestEvent, any>, "schema" | "context">
97+
| undefined,
98+
) =>
99+
nativeCreateYoga<RequestEvent>({
100+
...args,
94101
schema: schemaBuilder.toSchema(),
95102
context,
96103
});
@@ -118,19 +125,19 @@ export const rumble = <
118125
*/
119126
schemaBuilder,
120127
/**
121-
* The native yoga instance. Can be used to run an actual HTTP server.
128+
* Creates the native yoga instance. Can be used to run an actual HTTP server.
122129
*
123130
* @example
124131
*
125132
* ```ts
126133
import { createServer } from "node:http";
127-
* const server = createServer(yoga());
134+
* const server = createServer(createYoga());
128135
server.listen(3000, () => {
129136
console.info("Visit http://localhost:3000/graphql");
130137
});
131138
* ```
132139
*/
133-
yoga,
140+
createYoga,
134141
/**
135142
* A function for creating default objects for your schema
136143
*/

lib/types/rumbleInput.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ export type RumbleInput<
1111
* Your drizzle database instance
1212
*/
1313
db: DB;
14-
/**
15-
* Optional options for the native GraphQL Yoga server
16-
*/
17-
nativeServerOptions?:
18-
| Omit<YogaServerOptions<RequestEvent, any>, "schema" | "context">
19-
| undefined;
2014
/**
2115
* A function for providing context for each request based on the incoming HTTP Request.
2216
* The type of the parameter equals the HTTPRequest type of your chosen server.

0 commit comments

Comments
 (0)