Started with Moment and datetime

This commit is contained in:
Riccardo
2021-01-04 19:48:22 +01:00
parent 82055b4040
commit 4d021d6043
8 changed files with 113 additions and 47 deletions

View File

@@ -1,17 +1,40 @@
// import Appointment from '../../client/src/components/Appointment.js';
import Product from './models/product.js';
import Appointment from './models/appointment.js';
// import { createAppointment } from './resolvers/Mutation.js';
export const resolvers = {
Query: {
async allProducts() {
return await Product.find();
},
async allAppointments() {
return await Appointment.find();
},
async allProducts() {
return await Product.find();
},
},
Mutation: {
async createAppointment(root, {
input
}) {
return await Appointment.create(input);
},
async updateAppointment(root, {
_id,
input
}) {
return await Appointment.findOneAndUpdate({
_id
}, input, {
new: true
})
},
async deleteAppointment(root, {
_id
}) {
return await Product.findOneAndRemove({
_id
});
},
async createProduct(root, {
input
}) {

View File

@@ -19,11 +19,15 @@ type Feed {
type Mutation {
createAppointment(
title: String!,
description: String!,
timeStart: DateTime!,
timeEnd: DateTime!,
input: AppointmentInput
): Appointment!
updateAppointment(
_id: ID!,
input: AppointmentInput
): Appointment
deleteAppointment(
_id: ID!
) : Appointment
createProduct(
input: ProductInput
) : Product
@@ -65,23 +69,39 @@ type User {
appointments: [Appointment!]!
}
# Appointment model
type Appointment {
_id: ID!
title: String!
description: String!
timeStart: DateTime!
timeEnd: DateTime!
# dateStart: Date!
# dateEnd: Date!
timeStart: Time!
timeEnd: Time!
deleted: Boolean
# createdBy: User
# follows: [Follow!]!
# createdAt: DateTime!
}
input AppointmentInput {
title: String!
description: String!
# dateStart: Date!
# dateEnd: Date!
timeStart: Time!
timeEnd: Time!
}
# Product model
type Product {
_id: ID!
title: String!
qty: Int
}
input ProductInput {
title: String!
qty: Int
}
type Follow {
_id: ID!
@@ -89,11 +109,6 @@ type Follow {
user: User!
}
input ProductInput {
title: String!
qty: Int
}
input AppointmentOrderByInput {
description: Sort
@@ -107,3 +122,4 @@ enum Sort {
}
scalar DateTime
scalar Time