diff --git a/client/src/components/appointment/UpdateAppointment.js b/client/src/components/appointment/UpdateAppointment.js
index 32b1e10..50ed89c 100644
--- a/client/src/components/appointment/UpdateAppointment.js
+++ b/client/src/components/appointment/UpdateAppointment.js
@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import { useHistory } from 'react-router';
import { useMutation, gql, useQuery } from '@apollo/client';
-import { APPOINTMENTS_PER_PAGE } from '../../constants';
-import { APPOINTMENTS_QUERY } from './AppointmentList';
+// import { APPOINTMENTS_PER_PAGE } from '../../constants';
+// import { APPOINTMENTS_QUERY } from './AppointmentList';
import Datetime from 'react-datetime';
import "react-datetime/css/react-datetime.css";
diff --git a/client/src/components/layout/Header.js b/client/src/components/layout/Header.js
index af7b150..33e38aa 100644
--- a/client/src/components/layout/Header.js
+++ b/client/src/components/layout/Header.js
@@ -1,6 +1,6 @@
import React from 'react';
// import { useHistory } from 'react-router';
-import { Link, withRouter } from 'react-router-dom';
+import { Link } from 'react-router-dom';
// import { AUTH_TOKEN } from '../../constants';
const Header = () => {
@@ -17,6 +17,9 @@ const Header = () => {
{authToken ? (
{
diff --git a/server/src/models/appointment.js b/server/src/models/appointment.js
index ed792e2..2adde1e 100644
--- a/server/src/models/appointment.js
+++ b/server/src/models/appointment.js
@@ -24,6 +24,11 @@ const AppointmentSchema = new Schema({
deleted: {
type: Boolean,
required: false
+ },
+ user: {
+ type: mongoose.Schema.Types.ObjectId,
+ ref: "user",
+ required: false
}
});
export default mongoose.model('appointment', AppointmentSchema);
\ No newline at end of file
diff --git a/server/src/resolvers.js b/server/src/resolvers.js
index 5d99811..9691a39 100644
--- a/server/src/resolvers.js
+++ b/server/src/resolvers.js
@@ -1,5 +1,5 @@
import Appointment from './models/appointment.js';
-import User from './models/user.js'
+import User from './models/user.js';
import jwt from 'jsonwebtoken';
export const resolvers = {
diff --git a/server/src/resolvers/Mutation.js b/server/src/resolvers/Mutation.js
index c98e157..0fc9393 100644
--- a/server/src/resolvers/Mutation.js
+++ b/server/src/resolvers/Mutation.js
@@ -2,7 +2,7 @@ const bcrypt = require('bcryptjs');
const jwt = require('jsonwebtoken');
const { APP_SECRET } = require('../utils');
-function createAppointment(parent, args, context, info) {
+function createAppointment(parent, args, context) {
const { userId } = context;
const newAppointment = context.mongo.appointment.create({
@@ -16,7 +16,7 @@ function createAppointment(parent, args, context, info) {
return newAppointment;
}
-async function signup(parent, args, context, info) {
+async function signup(parent, args, context) {
const password = await bcrypt.hash(args.password, 10);
const user = await context.mongo.user.create({
data: { ...args, password }
@@ -30,7 +30,7 @@ async function signup(parent, args, context, info) {
};
}
-async function login(parent, args, context, info) {
+async function login(parent, args, context) {
const user = await context.mongo.user.findUnique({
where: { email: args.email }
});
@@ -54,18 +54,18 @@ async function login(parent, args, context, info) {
};
}
-async function follow(parent, args, context, info) {
+async function follow(parent, args, context) {
const { userId } = context;
const follow = await context.mongo.follow.findUnique({
where: {
linkId_userId: {
linkId: Number(args.linkId),
- userId: userId
+ userId
}
}
});
- if (Boolean(follow)) {
+ if (follow) {
throw new Error(
`Already followed the appointment: ${args.linkId}`
);
diff --git a/server/src/resolvers/Query.js b/server/src/resolvers/Query.js
index b68f879..c2fbc82 100644
--- a/server/src/resolvers/Query.js
+++ b/server/src/resolvers/Query.js
@@ -1,4 +1,4 @@
-async function feed(parent, args, context, info) {
+async function feed(parent, args, context) {
const where = args.filter
? {
diff --git a/server/src/resolvers/Subscription.js b/server/src/resolvers/Subscription.js
index bb4d0b5..54cbf82 100644
--- a/server/src/resolvers/Subscription.js
+++ b/server/src/resolvers/Subscription.js
@@ -1,26 +1,22 @@
-function newLinkSubscribe(parent, args, context, info) {
- return context.pubsub.asyncIterator("NEW_LINK")
+function newAppointmentSubscribe(parent, args, context) {
+ return context.pubsub.asyncIterator("NEW_APPOINTMENT");
}
const newAppointment = {
- subscribe: newLinkSubscribe,
- resolve: payload => {
- return payload
- },
-}
+ subscribe: newAppointmentSubscribe,
+ resolve: payload => payload,
+};
-function newFollowSubscribe(parent, args, context, info) {
- return context.pubsub.asyncIterator("NEW_FOLLOW")
+function newFollowSubscribe(parent, args, context) {
+ return context.pubsub.asyncIterator("NEW_FOLLOW");
}
const newFollow = {
subscribe: newFollowSubscribe,
- resolve: payload => {
- return payload
- },
-}
+ resolve: payload => payload,
+};
module.exports = {
newAppointment,
newFollow
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/server/src/schema.graphql b/server/src/schema.graphql
index f061385..50939c6 100644
--- a/server/src/schema.graphql
+++ b/server/src/schema.graphql
@@ -7,9 +7,7 @@ type Query {
orderBy: AppointmentOrderByInput
): Feed!
allAppointments: [Appointment]
- oneAppointment(
- _id: ID!
- ): Appointment
+ oneAppointment(_id: ID!): Appointment
allUsers: [User]
users: [User!]!
}
@@ -30,7 +28,7 @@ type Mutation {
deleted: Boolean
): Appointment!
updateAppointment(
- _id: ID!,
+ _id: ID!
title: String!
description: String
type: String!
@@ -38,21 +36,10 @@ type Mutation {
end: DateTime!
deleted: Boolean
): Appointment
- deleteAppointment(
- _id: ID!
- ) : Appointment
- signup(
- email: String!
- password: String!
- username: String!
- ): AuthPayload
- login(
- email: String!,
- password: String!
- ): AuthPayload
- follow(
- appointmentId: ID!
- ): Follow
+ deleteAppointment(_id: ID!): Appointment
+ signup(email: String!, password: String!, username: String!): AuthPayload
+ login(email: String!, password: String!): AuthPayload
+ follow(appointmentId: ID!): Follow
}
type Subscription {
@@ -66,13 +53,13 @@ type User {
username: String!
email: String!
password: String!
- # appointments: [Appointment!]!
+ appointments: [Appointment!]!
}
-input UserInput{
+input UserInput {
username: String!
email: String!
password: String!
- # appointments: [Appointment!]!
+ appointments: [Appointment!]!
}
type AuthPayload {
token: String
@@ -88,9 +75,8 @@ type Appointment {
start: DateTime!
end: DateTime!
deleted: Boolean
- createdBy: User
+ user: User
# follows: [Follow!]!
- # createdAt: DateTime!
}
input AppointmentInput {
title: String!
@@ -99,11 +85,10 @@ input AppointmentInput {
start: DateTime!
end: DateTime!
deleted: Boolean
- }
+}
input AppointmentOrderByInput {
title: Sort
desc: Sort
- # createdAt: Sort
}
# Follow schemas