Skip to content

Assistive-Tech-2307/user_service

Repository files navigation

README

Table of Contents

About this App

This application has 1 endpoint that currently allows for 4 different implementations. You can log in and create a session, create a comment, delete a comment, and get all of a specific category's comments. This API feeds into a website called AI AT Ally that helps match assistive technologies to disabilities.

Production Sites

Associated Repos

Ruby version

ruby 3.2.2

Preloaded seeds

User.create(name: "Rosa Marcellino", email: "rosa@aol.com", password: "rosaslaw10!")
User.create(name: "Amy Rowley", email: "amy@aol.com", password: "Rowley10!")
User.create(name: "Oliver Brown", email: "brown@aol.com", password: "Brown10!")

Install Ruby with Brew

  • In terminal, in any directory
$ brew update
$ brew install ruby-build
$ brew install rbenv

$ rbenv install 3.2.2
$ rbenv global 3.2.2

Install

  • pull respository down
  • move into directory
  • in terminal bundle
  • in terminal rails db:{create,migrate,seed}
  • in terminal rails server defaults to 3001

reset database

  • in terminal rails db:{drop,create,migrate,seed}

Database

Schema Setup

GraphiQL Endpoints

  • in browser http://localhost:3001/graphiql

GraphQL Endpoints

Create session

request
POST http://localhost:3001/graphql

In query

mutation Session{
   sessionCreate(email:"<user's email>", password:"<user's password"){
       id
       email
   }
}

example

mutation Session{
   sessionCreate(email:"rosa@aol.com", password:"rosaslaw10!"){
       id
       email
   }
}

sample response

{
    "data": {
        "sessionCreate": {
            "id": "1",
            "email": "rosa@aol.com"
        }
    }
}

Create Comment

request
POST /graphql

query

mutation {
    commentCreate(
        input: {
            title: "this is my title",
            link: "link.com",
            description: "this is my description",
            userComment: "this is my comment",
            rating: true,
            category: "Blindness",
            userId: 1
        }
    ) {
        id
        title
        link
        description
        userComment
        rating
        categoryId
        userId
    }
}

response

{
    "data": {
        "commentCreate": {
            "id": "2",
            "title": "this is my title",
            "link": "link.com",
            "description": "this is my description",
            "userComment": "this is my comment",
            "rating": true,
            "categoryId": 1,
            "userId": 1
        }
    }
}

Delete Comment

request
POST "/graphql

query

mutation {
    commentDelete(
        input: {
            id: 2
        }
    ) {
        id
        title
        link
        description
        userComment
        rating
        categoryId
        userId
    }
}

regular response

{
    "data": {
        "commentDelete": {
            "id": "2",
            "title": "this is my title",
            "link": "link.com",
            "description": "this is my description",
            "userComment": "this is my comment",
            "rating": true,
            "categoryId": 1,
            "userId": 1
        }
    }
}

error response (if comment couldn't be deleted, usually because comment id doesn't exist)

{
    "data": {
        "commentDelete": null
    },
    "errors": [
        {
            "message": "Comment not deleted.",
            "locations": [
                {
                    "line": 2,
                    "column": 5
                }
            ],
            "path": [
                "commentDelete"
            ]
        }
    ]
}

Get All of a Specific Category's Comments

request
POST /graphql

query

{
    allCategoryComments(
        categoryId: 1
    ) {
        id
        title
        link
        description
        userComment
        rating
        categoryId
        userId
    }
}

response

{
    "data": {
        "allCategoryComments": [
            {
                "id": "1",
                "title": "this is my title",
                "link": "link.com",
                "description": "this is my description",
                "userComment": "this is my comment",
                "rating": true,
                "categoryId": 1,
                "userId": 1
            },
            {...},
            {...}
        ]
    }
}

Contributors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages