@@ -30,22 +30,29 @@ export const db = drizzle(
3030
3131*/
3232
33- const { abilityBuilder, schemaBuilder, arg, object, query, pubsub, yoga } =
34- rumble ( {
35- // here we pass the db instance from above
36- db,
37- // this is how we can define a context callback
38- // it takes a request object as an argument and returns the objects you want in the request context
39- // similar to the context callback in express or similar frameworks
40- // the type of the request parameter may vary based on the HTTP library you are using
41- context ( request ) {
42- return {
43- // for our usecase we simply mock a user ID to be set in the context
44- // this will allow us to perform permission checks based on who the user is
45- userId : 2 ,
46- } ;
47- } ,
48- } ) ;
33+ const {
34+ abilityBuilder,
35+ schemaBuilder,
36+ arg,
37+ object,
38+ query,
39+ pubsub,
40+ createYoga,
41+ } = rumble ( {
42+ // here we pass the db instance from above
43+ db,
44+ // this is how we can define a context callback
45+ // it takes a request object as an argument and returns the objects you want in the request context
46+ // similar to the context callback in express or similar frameworks
47+ // the type of the request parameter may vary based on the HTTP library you are using
48+ context ( request ) {
49+ return {
50+ // for our usecase we simply mock a user ID to be set in the context
51+ // this will allow us to perform permission checks based on who the user is
52+ userId : 2 ,
53+ } ;
54+ } ,
55+ } ) ;
4956
5057/*
5158
@@ -304,7 +311,7 @@ schemaBuilder.mutationFields((t) => {
304311
305312// when we are done defining the objects, queries and mutations,
306313// we can start the server
307- const server = createServer ( yoga ( ) ) ;
314+ const server = createServer ( createYoga ( ) ) ;
308315server . listen ( 3000 , ( ) => {
309316 console . info ( "Visit http://localhost:3000/graphql" ) ;
310317} ) ;
0 commit comments