WIP on resolvers/GraphQL schema
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
"keywords": [],
|
||||
"author": "Jason Ross",
|
||||
"license": "ISC",
|
||||
"module": "esnext",
|
||||
"packageManager": "pnpm@10.13.1",
|
||||
"engines": {
|
||||
"node": ">=22.17.0"
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
function loginUserResolver() {
|
||||
return {
|
||||
Subscription: {
|
||||
loginUser: {
|
||||
subscribe: async ({ email, password }: { email: string; password: string; }, { pubsub }: { pubsub }: { EventEmitter }) => {
|
||||
loginUser({ email, password });
|
||||
return pubsub.asyncIterator('LOGIN_SUCCESS' || 'LOGIN_FAILURE');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function logoutUserResolver() {
|
||||
return {
|
||||
Subscription: {
|
||||
logoutUser: {
|
||||
subscribe: async ({ email }: { email: string }, { pubsub }: { pubsub }: { EventEmitter }) => {
|
||||
logoutUser({ email });
|
||||
return pubsub.asyncIterator('LOGOUT_SUCCESS' || 'LOGOUT_FAILURE');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function createUserResolver() {
|
||||
return {
|
||||
Mutation: {
|
||||
createUser: async ({ email, password }: { email: string; password: string; }) => {
|
||||
const user = await createUser({ email, password });
|
||||
return user ? "USER_CREATED_SUCCESS" : "USER_CREATION_FAILED";
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user