mentorenwahl/docker/backend_old/src/schema/query.ts
2022-01-08 13:29:22 +01:00

34 lines
700 B
TypeScript

import { queryType, idArg, nonNull } from "nexus";
import { Context } from "../context";
import { User } from "./user";
export const Query = queryType({
definition(t) {
t.nonNull.boolean("ok", {
resolve() {
return true;
},
});
t.field("user", {
type: User,
args: {
id: nonNull(idArg()),
},
resolve(_root, args, ctx: Context) {
return ctx.prisma.user.findUnique({
where: {
id: args.id,
},
});
},
});
t.nonNull.list.nonNull.field("users", {
type: User,
resolve(_root, _args, ctx: Context) {
return ctx.prisma.user.findMany();
},
});
},
});