Kelly Copley
11/02/2021, 4:07 PMJoshua Ramin
11/02/2021, 4:13 PMKelly Copley
11/02/2021, 4:20 PMKelly Copley
11/02/2021, 4:20 PMreturn prisma.player.update({ where: { id: playerToUpdate }, data: args.data });
Kelly Copley
11/02/2021, 4:23 PMJoshua Ramin
11/02/2021, 4:24 PMp.field("updateProfile", {
type: "profile",
args: {
profileID: idArg(),
firstname: stringArg(),
lastname: stringArg(),
phone: PhoneNumberResolver,
},
resolve: async (
_,
{ profileID, firstname, lastname, phone }: any
): Promise<any> => {
const profile = await prisma.profile.update({
where: { profileID },
data: {
firstname,
lastname,
phone,
},
});
pubsub.publish("updatedProfile", profile);
return profile;
},
});
Joshua Ramin
11/02/2021, 4:24 PMKelly Copley
11/02/2021, 4:28 PMJoshua Ramin
11/02/2021, 4:28 PMKelly Copley
11/02/2021, 4:35 PMexport const UpdatePlayerInput = inputObjectType({
name: 'UpdatePlayerInput',
definition (t) {
t.string('firstName');
t.string('lastName');
t.dateTime('dateOfBirth');
t.string('jerseySize');
t.string('userRelationShip');
},
});
Kelly Copley
11/02/2021, 4:35 PMexport const UpdatePlayer = mutationField('updatePlayer', {
type: PlayerType,
args: {
id: nonNull(stringArg()),
data: UpdatePlayerInput,
},
resolve (_root, { id, data }, { session, prisma }) {
return prisma.player.update({ where: { id: id }, data });
},
});
Joshua Ramin
11/02/2021, 4:46 PMKelly Copley
11/02/2021, 5:34 PM