Skip to content

eport01/questions_graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Questions API

Table of Contents

About the Project

Setup

Built With

Endpoints

  • Endpoints are run through GraphQL queries and mutations
Find All Users

Returns a list of all current users in database.

query {
    users {
        id
        name
        email
    }  
}

Expected Response:

{
   "data": {
       "users": [
           {
               "id": 1,
               "name": "Louie"
           },
           {
               "id": 2,
               "name": "Zoe"
           }
       ]  
   }
}

Create a New User

Creates a new user with authenticated password

mutation {
  createUser(input:{
    name: "Louie",
    authProvider: {
      credentials: {
        email: "laure@zoe.com",
        password: "123456"
      }
    }}
  ) {
        user {
          name 
          email
        }
        token
      }
    
  }

Expected Response:

{
 "data": {
   "createUser": {
     "user": {
       "name": "Louie"
     },
     "token": "mjAF0bjAdiIrb4UqXglHjR8VnXw=--E8144N+acp2SFVgI--2xEf3W43EIuc2b7VKTzbxQ=="
   }
 }
}

Login A User

mutation {
  signinUser(input:{credentials: {
    email: "email@example.com",
    password: "123456"
  }}){
    token
    user {
      id
    }
  }
}  

Expected Response:

{
 "data": {
   "signinUser": {
     "token": "CpKhgC4UyYLcgHBkgRnAZzDgYQ==--lfHRCnMeCJpELskr--4JMVavDhOrTTVHdZiuU5ww==",
     "user": {
       "id": "7"
     }
   }
 }
}

Find All Tech Questions

Returns a list of all Tech Questions in the database

query {
    tQuestions {
        id
        question
        qType
    }  
}

Expected Response:

{
 "data": {
   "tQuestions": [
     {
       "id": "1",
       "question": "Clear your mind must be, if you are to find the villains behind this plot.",
       "qType": 0
     },
     {
       "id": "2",
       "question": "Soon will I rest, yes, forever sleep. Earned it I have. Twilight is upon me, soon night must fall.",
       "qType": 0
     },
     {...}
   ]}
}

Find All Behavioral

Returns a list of all Behavioral Questions in the database

query {
  bQuestions {
    id 
    question
  }
}

Expected Response:

{
 "data": {
   "bQuestions": [
     {
       "id": "1",
       "question": "Why do you want to work for X company?"
     },
     {
       "id": "2",
       "question": "What are you looking for in your next role?"
     },
     {
       "id": "3",
       "question": "Tell me about a time when you had a conflict with a co-worker."
     },
     {...}
   ]}
}

Get a User's TQuestions, BQuestions, and Todo Items

Returns all of a user's questions and todo list items

query {
  user(id:1){
    id 
    name 
    email
    token   
    todos {
        id
        item  
        userId 
        createdAt
        updatedAt 
    } 
    userTQuestions {
      id
      userId
      tQuestionId
     	answer 
      status
      tQuestion {
        question
        qType
      }
    } 
    userBQuestions {
      id
      userId
      bQuestionId
     	answer 
      status
      bQuestion {
        question
      }
    } 

  }
}

Expected Response:

{
   "data": {
       "user": {
           "id": "1",
           "name": "Louie",
           "email": "nkyse@zoe.com",
           "token": "123456",
           "todos": [
               {
                   "id": "1",
                   "item": "Take a nap",
                   "userId": 1,
                   "createdAt": "2023-03-31T18:30:19Z",
                   "updatedAt": "2023-03-31T18:30:19Z"
               },
               {
                   "id": "8",
                   "item": "Apply for 2 jobs",
                   "userId": 1,
                   "createdAt": "2023-03-31T18:55:04Z",
                   "updatedAt": "2023-03-31T18:55:04Z"
               }
           ],
           "userTQuestions": [
               {
                   "id": "2",
                   "userId": 1,
                   "tQuestionId": 3,
                   "answer": "steve !",
                   "status": 0,
                   "tQuestion": {
                       "question": "What are the pros and cons of your chosen technology?",
                       "qType": 3
                   }
               }
           ],
           "userBQuestions": [
               {
                   "id": "2",
                   "userId": 1,
                   "bQuestionId": 3,
                   "answer": "this is hard!!",
                   "status": 0,
                   "bQuestion": {
                       "question": "Tell me about a time when you had a conflict with a co-worker."
                   }
               },
               {
                   "id": "3",
                   "userId": 1,
                   "bQuestionId": 5,
                   "answer": "good question",
                   "status": 0,
                   "bQuestion": {
                       "question": "What project are you currently working on?"
                   }
               }
           ]
       }
   }
}

Answer a Tech Question for a User

Saves that question and answer to that user

mutation {
  createUserTQuestion(input: {userId: 1, tQuestionId: 3, answer: "hello there!"}){
    userTQuestion {
      id
      userId
      tQuestionId
      status
      answer
      tQuestion {
        question
      }
    }
  }
}

Expected Response:

{
 "data": {
   "createUserTQuestion": {
     "userTQuestion": {
       "id": "10",
       "userId": 1,
       "tQuestionId": 3,
       "status": 1,
       "answer": "hello there!",
       "tQuestion": {
         "question": "Ow, ow, OW! On my ear you are!"
       }
     }
   }
 }
}

Answer a Behavioral Question

After logging in, a user can answer and save a question

mutation {
  createUserBQuestion(input: {bQuestionId: 1, answer: "hello"})
    {
     userBQuestion{
      id 
      status 
      answer
      user {
        name
      }
      bQuestion {
        question
      }
    }  
  
    }
}

Expected Response:

{
 "data": {
   "createUserBQuestion": {
     "userBQuestion": {
       "id": "25",
       "status": 1,
       "answer": "hello",
       "user": {
         "name": "Test User"
       },
       "bQuestion": {
         "question": "Why do you want to work for X company?"
       }
     }
   }
 }
}

Update a User's Tech Question

The status of the question can be updated so the user can star or unstar a question. The answer can also be updated

mutation{
  updateUserTQuestion(input:{id: 11, tQuestionId: 3, status: 2, answer: "I want chocolate!"}) 
  
 { userTQuestion{
    id
    answer 
    status 
  	tQuestionId 

  }}
}

Expected Response:

{
 "data": {
   "updateUserTQuestion": {
     "userTQuestion": {
       "id": "11",
       "answer": "I want chocolate!",
       "status": 2,
       "tQuestionId": 3
     }
   }
 }
}

Update a User's Behavioral Question

The status of the question can be updated so the user can star or unstar a question. The answer can also be updated

mutation {
  updateUserBQuestion(input: {id: 1, userId: 1, bQuestionId: 1, answer: "hello there!", status: 1}){
    userBQuestion {
    id 
    answer
    userId
    bQuestionId
    status
      
    
    }
  }
}

Expected Response:

{
 "data": {
   "updateUserBQuestion": {
     "userBQuestion": {
       "id": "1",
       "answer": "hello there!",
       "userId": 1,
       "bQuestionId": 1,
       "status": 1
     }
   }
 }
}

Create Todo List Item

Creates an item on a user's todo list

mutation {
  createTodo(input:{userId:1, item: "Take a nap"}){
    todo {
      id 
      userId 
      item 
      createdAt
      updatedAt
    }
  }
   
}

Expected Response:

{
 "data": {
   "createTodo": {
     "todo": {
       "id": "5",
       "userId": 1,
       "item": "Take a nap",
       "createdAt": "2023-03-31T18:30:29Z",
       "updatedAt": "2023-03-31T18:30:29Z"
     }
   }
 }
}

Delete Todo List Item

Deletes an item on a user's todo list

mutation {
  deleteTodo(input:{id:7}){
    message 
  }
}

Expected Response:

{
   "data": {
       "deleteTodo": {
           "message": "Item successfully deleted from todo list!"
       }
   }
}

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors