snowballtools-base/packages/backend/src/resolvers.ts
neerajvijay1997 e4c099f8c3 Refactor database setup and add user context to GQL requests (#17)
* Add context to each request

* Implement get user db query

* Move constants to a separate file

* Refactor database init method
2024-02-01 11:37:57 +05:30

17 lines
326 B
TypeScript

import { Database } from './database';
export const createResolvers = async (db: Database): Promise<any> => {
return {
Query: {
user: (
_: any,
__: any,
// TODO: add custom type for context
context: any
) => {
return db.getUser(context.userId);
}
}
};
};