Delete Appointment works
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
"graphql-compose": "^7.23.0",
|
||||
"graphql-compose-connection": "^8.0.1",
|
||||
"graphql-compose-mongoose": "^9.0.0",
|
||||
"graphql-depth-limit": "^1.1.0",
|
||||
"graphql-middleware": "^6.0.0",
|
||||
"graphql-tools": "^7.0.2",
|
||||
"jsonwebtoken": "8.5.1",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import express from 'express';
|
||||
import dotenv from 'dotenv';
|
||||
import { graphqlHTTP } from 'express-graphql';
|
||||
import depthLimit from 'graphql-depth-limit'
|
||||
import { ApolloServer, PubSub } from 'apollo-server-express';
|
||||
import mongoose from 'mongoose';
|
||||
import schema from './schema.js';
|
||||
@@ -26,6 +27,7 @@ app.use(cors());
|
||||
|
||||
app.use('/djhb58fytkh476dk45yh49', graphqlHTTP({
|
||||
schema: schema,
|
||||
validationRules: [depthLimit(3)],
|
||||
graphiql: true
|
||||
}));
|
||||
|
||||
|
||||
@@ -66,55 +66,22 @@ export const resolvers = {
|
||||
};
|
||||
},
|
||||
|
||||
// async login(parent, args, context, info) {
|
||||
// console.log(args);
|
||||
// const user = await User.findOne({
|
||||
// email: args.email
|
||||
// });
|
||||
|
||||
// if (!user) {
|
||||
// throw new Error('No such user found');
|
||||
// }
|
||||
|
||||
// const pwd = await bcrypt.hash(args.password, 10);
|
||||
// console.log(pwd);
|
||||
// console.log(args.password)
|
||||
// console.log(user.password);
|
||||
|
||||
// const valid = await bcrypt.compare(
|
||||
// args.password,
|
||||
// user.password
|
||||
// );
|
||||
// if (!valid) {
|
||||
// throw new Error('Invalid password');
|
||||
// }
|
||||
|
||||
// const token = jwt.sign({ userId: user.id }, process.env.APP_SECRET);
|
||||
|
||||
// return {
|
||||
// token,
|
||||
// user
|
||||
// };
|
||||
// },
|
||||
|
||||
async createAppointment(parent, args, context, info) {
|
||||
return await Appointment.create(args);
|
||||
},
|
||||
async updateAppointment(root, {
|
||||
_id,
|
||||
input
|
||||
}) {
|
||||
async updateAppointment(parent, args, context, info) {
|
||||
return await Appointment.findOneAndUpdate({
|
||||
_id
|
||||
}, input, {
|
||||
args
|
||||
}, args, {
|
||||
new: true
|
||||
})
|
||||
},
|
||||
async deleteAppointment(root, {
|
||||
_id
|
||||
}) {
|
||||
return await Product.findOneAndRemove({
|
||||
_id
|
||||
async deleteAppointment(parent, args, context, info) {
|
||||
console.log(args);
|
||||
return await Appointment.deleteOne({ _id: args._id }).then(function () {
|
||||
console.log("Data deleted"); // Success
|
||||
}).catch(function (error) {
|
||||
console.log(error); // Failure
|
||||
});
|
||||
},
|
||||
async createProduct(root, {
|
||||
|
||||
@@ -24,11 +24,12 @@ type Mutation {
|
||||
description: String!
|
||||
start: String!
|
||||
end: String!
|
||||
# input: AppointmentInput
|
||||
): Appointment!
|
||||
updateAppointment(
|
||||
_id: ID!,
|
||||
input: AppointmentInput
|
||||
title: String!
|
||||
description: String!
|
||||
start: String!
|
||||
): Appointment
|
||||
deleteAppointment(
|
||||
_id: ID!
|
||||
|
||||
Reference in New Issue
Block a user