소스 검색

fixed signup schema.

Tomi Cvetic 5 년 전
부모
커밋
f6f2a97e1a
3개의 변경된 파일7개의 추가작업 그리고 18개의 파일을 삭제
  1. 2 1
      .vscode/settings.json
  2. 1 10
      backend/schema.graphql
  3. 4 7
      backend/src/resolvers.js

+ 2 - 1
.vscode/settings.json

@@ -1,5 +1,6 @@
 {
     "prettier.semi": false,
     "standard.autoFixOnSave": true,
-    "editor.formatOnSave": true
+    "editor.formatOnSave": true,
+    "prettier.bracketSpacing": false
 }

+ 1 - 10
backend/schema.graphql

@@ -24,16 +24,7 @@ type Query {
 
 type Mutation {
   createUser(name: String!, email: String!, password: String!): User!
-  createTraining(
-    title: String!
-    type: TrainingType!
-    content: [Input]!
-    createdAt: DateTime!
-    trainingDate: DateTime!
-    participants: [Input]!
-    ratings: [Input]!
-    published: Boolean!
-  ): Training!
+  createTraining(data: TrainingCreateInput!): Training!
   login(email: String!, password: String!): User!
   signup(name: String!, email: String!, password: String!): User!
   logout: String!

+ 4 - 7
backend/src/resolvers.js

@@ -9,10 +9,7 @@ const Query = {
   trainings: forwardTo('db'),
   me: (parent, args, context, info) => {
     if (!context.request.userId) throw new Error('Not logged in.')
-    return context.db.query.user(
-      { where: { id: context.request.userId } },
-      info
-    )
+    return context.db.query.user({ where: { id: context.request.userId } }, info)
   }
 }
 
@@ -39,14 +36,14 @@ const Mutation = {
     return user
   },
   signup: async (parent, args, ctx, info) => {
-    args.email = args.email.toLowerCase()
+    const email = args.email.toLowerCase()
     const password = await bcrypt.hash(args.password, 10)
     const user = await ctx.db.mutation.createUser(
       {
         data: {
           ...args,
-          password,
-          permissions: { set: ['USER'] }
+          email,
+          password
         }
       },
       info