Skip to content

2110CapstoneProject/not-fur-gotten-be

Repository files navigation

Screen Shot 2022-06-26 at 10 42 38

languages PRs rspec simplecov graphql

Table of Contents

Project Description
Backend Features
System Requirements
Gems Utilized
Technologies Used
Setup
Database Schema
API Endpoints
Authors
Additional Project Information

Project Description

"Not Fur-gotten" is a group project created over the course of 14 days by members of the Turing School of Software and Design. It is designed to allow pet owners to find new owners for pets that they are unable to care for any longer. Pet owners can post their pets on Not Fur-Gotten with a description and some information about the pet, and then pet adopters can post applications for the pets. Eventually, the owner can select a new owner for their pet from all the applicants.

Backend Features

  • PostgreSQL Database for Pets and Applications tables
  • Utilize GraphQL to create endpoints for queries and mutations of Pets and Applications tables
  • Implement Github Actions for CI/CD

System Requirements

Ruby and Rails

  • Ruby -V 2.7.2
  • Rails -V 5.2.6

Technologies Used

Ruby on Rails Atom Visual Studio Code GitHub Actions GitHub Git Postgresql Postman Heroku GraphQL

Gems Utilized

  • rack-cors
  • graphql
  • graphiql-rails
  • rspec
  • pry
  • simplecov
  • shoulda-matchers

Setup

  1. Fork and clone this Repo from GitHub.
  2. In your terminal use $ git clone <ssh or https path>
  3. Change into the cloned directory using $ cd not-fur-gotten-be
  4. Install the gem packages using $ bundle install
  5. Database Migrations can be setup by running:
$ rails rake db:{drop,create,migrate,seed}

Database Schema

DB schema

Our application is based on a one to many relationship between pets and applications - each pet can have many applications. We chose to include original owner user information in the pet. New adoptive owner information is included in the application.

API Endpoints

All queries are made using a single GraphQL endpoint:

post to '/graphql'

All queries must be in GraphQL format in the body of the request. Note the camelCase.

This application supports the following Graphql queries:

Query for getAllPets as GraphQL:

{
  getAllPets {
    id
    name
    age
    gender
    description
    species
    ownerStory
    ownerEmail
    ownerName
    image
    applications {
      name
      email
      description
    }
  }
}

Response for getAllPets:

{
    "data": {
        "getAllPets": [
            {
                "id": "1",
                "name": "Clifford",
                "age": 2,
                "gender": "M",
                "description": "Big Red Dog, likes kids",
                "species": "dog",
                "ownerStory": "My owner is going into assisted living next month and he is worried about what will happen to me",
                "ownerEmail": "[email protected]",
                "ownerName": "Virgil",
                "image": "https://images.unsplash.com/photo-1585559700398-1385b3a8aeb6?ixlib=rb-1.2.1&ixid=MnwxM[…]G90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80",
                "applications": [
                    {
                        "name": "Joe",
                        "email": "[email protected]",
                        "description": "I have a large yard and like to go for hikes"
                    }
                ]
            },
            {
                "id": "2",
                "name": "Garfield",
                "age": 6,
                "gender": "M",
                "description": "Fat orange cat",
                "species": "cat",
                "ownerStory": "My owner is going into assisted living next month and he is worried about what will happen to me",
                "ownerEmail": "[email protected]",
                "ownerName": "Virgil",
                "https://images.unsplash.com/photo-1536590158209-e9d615d525e4?ixlib=rb-1.2.1&ixid=MnwxM[…]G90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80",
                "applications": [
                    {
                        "name": "Kim",
                        "email": "[email protected]",
                        "description": "I love cats and live in an apartment"
                    },
                    {
                        "name": "Kumar",
                        "email": "[email protected]",
                        "description": "I really want another cat"
                    }
                ]
            },
            {
                "id": "3",
                "name": "Nermal",
                "age": 3,
                "gender": "F",
                "description": "Gray Tabby",
                "species": "cat",
                "ownerStory": "My owner is terminally ill with cancer and only has about 6 months to find me a home",
                "ownerEmail": "[email protected]",
                "ownerName": "Ethel",
                "https://images.unsplash.com/photo-1582797493098-23d8d0cc6769?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MjE2fHxncmF5JTIwdGFiYnklMjBjYXR8ZW58MHwxfDB8fA%3D%3D&auto=format&fit=crop&w=800&q=60",
                "applications": [
                    {
                        "name": "Harold",
                        "email": "[email protected]",
                        "description": "I love cats and would like to help out Ethel"
                    }
                ]
            }
        ]
    }
}

Query for getPetById(id: "1") as GraphQL:

{
  getPetById(id: "1")
  {
    id
    name
    age
    gender
    description
    species
    ownerStory
    ownerEmail
    ownerName
    image
    applications {
      name
      email
      description
    }
  }
}

Response for getPetById(id: "1"):

{
    "data": {
        "getPetById": {
            "id": "1",
            "name": "Clifford",
            "age": 2,
            "gender": "M",
            "description": "Big Red Dog, likes kids",
            "species": "dog",
            "ownerStory": "My owner is going into assisted living next month and he is worried about what will happen to me",
            "ownerEmail": "[email protected]",
            "ownerName": "Virgil",
            "image": "https://images.unsplash.com/photo-1585559700398-1385b3a8aeb6?ixlib=rb-1.2.1&ixid=MnwxM[…]G90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80",
            "applications": [
                {
                    "name": "Joe",
                    "email": "[email protected]",
                    "description": "I have a large yard and like to go for hikes"
                }
            ]
        }
    }
}

Mutation to createPet

mutation {
  createPet(input: {
    name: "Kitty",
    age: 9,
    gender: "F",
    description: "siamese cat",
    species: "cat",
    ownerStory: "My owner has to go to assisted living very soon and cannot take me, she really worries where I end up",
    ownerEmail: "[email protected]",
    ownerName: "Dorothy",
    "image": "https://images.unsplash.com/photo-1585559700398-1385b3a8b6?ixlib=rb-1.2.1&ixid=MnwxM[…]G90by1wYWdlfHx8fGVuB8fHx8&auto=format&fit=crop&w=774&q=80",
    }) {
      pet {
        id,
        name,
        gender,
        description,
        species,
        ownerStory,
        ownerEmail,
        ownerName
        image
      }
    errors
    }
  }

Response for createPet:

{
    "data": {
        "createPet": {
            "pet": {
                "id": "23",
                "name": "Kitty",
                "gender": "F",
                "description": "siamese cat",
                "species": "cat",
                "ownerStory": "My owner has to go to assisted living very soon and cannot take me, she really worries where I end up",
                "ownerEmail": "[email protected]",
                "ownerName": "Dorothy",
                "image": "https://images.unsplash.com/photo-1585559700398-1385b3a8b6?ixlib=rb-1.2.1&ixid=MnwxM[…]G90by1wYWdlfHx8fGVuB8fHx8&auto=format&fit=crop&w=774&q=80",
            },
            "errors": []
        }
    }
}


Mutation to createPet with name missing (creates error)

mutation {
  createPet(input: {
    age: 9,
    gender: "F",
    description: "siamese cat",
    species: "cat",
    ownerStory: "My owner has to go to assisted living very soon and cannot take me, she really worries where I end up",
    ownerEmail: "[email protected]",
    ownerName: "Dorothy",
    "image": "https://images.unsplash.com/photo-1585559700398-1385b3a8b6?ixlib=rb-1.2.1&ixid=MnwxM[…]G90by1wYWdlfHx8fGVuB8fHx8&auto=format&fit=crop&w=774&q=80",
    }) {
      pet {
        id,
        name,
        gender,
        description,
        species,
        ownerStory,
        ownerEmail,
        ownerName
        image
      }
    errors
    }
  }

Response for createPet with error example:

{
    "errors": [
        {
            "message": "Argument 'name' on InputObject 'CreatePetInput' is required. Expected type String!",
            "locations": [
                {
                    "line": 2,
                    "column": 20
                }
            ],
            "path": [
                "mutation",
                "createPet",
                "input",
                "name"
            ],
            "extensions": {
                "code": "missingRequiredInputObjectAttribute",
                "argumentName": "name",
                "argumentType": "String!",
                "inputObjectType": "CreatePetInput"
            }
        }
    ]
}

Mutation to createApplication

mutation {
    createApplication(input: {
        name: "Bob",
        email: "[email protected]",
        description: "I love all animals and want to help out the owner.",
        petId: 2
        }) {
        application {
            id,
            name,
            email,
            description
            petId
        }
        errors
        }
    }

Response for createApplication:

{
    "data": {
        "createApplication": {
            "application": {
                "id": "21",
                "name": "Bob",
                "email": "[email protected]",
                "description": "I love all animals and want to help out the owner.",
                "petId": 2
            },
            "errors": []
        }
    }
}

Mutation to createApplication with name missing (creates error)

mutation {
    createApplication(input: {
        email: "[email protected]",
        description: "I love all animals and want to help out the owner.",
        petId: 2
        }) {
        application {
            id,
            name,
            email,
            description
            petId
        }
        errors
        }
    }

Response for createApplication with error example:

{
    "errors": [
        {
            "message": "Argument 'name' on InputObject 'CreateApplicationInput' is required. Expected type String!",
            "locations": [
                {
                    "line": 2,
                    "column": 30
                }
            ],
            "path": [
                "mutation",
                "createApplication",
                "input",
                "name"
            ],
            "extensions": {
                "code": "missingRequiredInputObjectAttribute",
                "argumentName": "name",
                "argumentType": "String!",
                "inputObjectType": "CreateApplicationInput"
            }
        }
    ]
}

AUTHORS:

Backend Team
  • Kerri Hoffmann: LinkedIn GitHub
  • Karan Mehta: LinkedIn GitHub
  • Croix Kimmel: LinkedIn GitHub
Frontend Team
  • Lexy Newby: LinkedIn GitHub
  • Stevie Ambroise: LinkedIn GitHub
  • Ethan Tweitmann: LinkedIn GitHub
  • Christine Rowland: LinkedIn GitHub

Additional Project Information

Back to top

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages