Skip to content

A web-based API, integrated with GraphQL, generates packing lists for different trip types.

Notifications You must be signed in to change notification settings

packmate/packmate_be

Repository files navigation

PackMate Backend 🎣 ⛺🥾 ✔️

build status coverage

Welcome to the backend repository for PackMate, an app designed to help you plan and organize your adventure necessities for every trip. This repository focuses on the backend functionality and utilizes GraphQL, a powerful query language, to efficiently handle data retrieval and manipulation.

  • Features

    • Public (non-authenticated) users can access all causes on the platform
    • Continous Integration with CircleCI
    • Continous Deployment with Heroku
    • GraphQL server application
  • Links

  • Let's Connect ✉️

    Young Heon Koh Margaret Daly
    LinkedIn LinkedIn
    Github Github

Built With

Ruby Rails GraphQL Heroku PostgreSQL CircleCI

API Endpoint

POST request to https://packmate-be-d3fb267b5fee.herokuapp.com/graphql

Query Examples

Items by Category

categories: "Camping", "Hiking", "Fishing", "Climbing", "Kayaking", "Mountain Biking", "Backpacking", "Everything"

Request Body

query{
  items(category:"Camping") {
    id
    name
  }
}

Response Body status code 200

{
    "data": {
        "items": [
            {
                "id": "1",
                "name": "Tent"
            },
            {
                "id": "2",
                "name": "Flashlight"
            },
            {
                "id": "3",
                "name": "Sleeping bag"
            },
          ...
        ]
    }
}      

Mutation Examples

Create a List

Successful Request Body

mutation{
  createList(input:{
    name: "My Second List"
    tripType: "Hiking"
    items: ["Hiking Boots", "Sunscreen"]
  }){
    list {
      id
      name
      tripType
      items {
        id
        name
      }
      createdAt
      updatedAt
    }
    errors
  }
}

Response Body status code 200

{
  "data": {
    "createList": {
      "list": {
        "id": "2",
        "name": "My Second List",
        "tripType": "Hiking",
        "items": [
          {
            "id": "4",
            "name": "Hiking Boots"
          },
          {
            "id": "11",
            "name": "Sunscreen"
          }
        ],
        "createdAt": "2023-07-10T20:28:34Z",
        "updatedAt": "2023-07-10T20:28:34Z"
      },
      "errors": []
    }
  }
}

Failure Request Body

mutation{
  createList(input:{
    name: ""
    tripType: "Fishing"
    items: ["Fishing pole", "Bait"]
  }){
    list {
      id
      name
      tripType
      items {
        id
        name
      }
      createdAt
      updatedAt
    }
    errors
  }
}

Response Body status code 400

{
  "data": {
    "createList": null
  },
  "errors": [
    {
      "message": "Name cannot be blank",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "createList"
      ]
    }
  ]
}

Getting Started

To set up the PackMate backend locally or contribute to its development, follow these steps:

  1. Clone or Fork the repository: git clone https://github.com/your-username/PackMate-Backend.git

  2. Install dependencies: bundle install

  3. Configure the database: Update the database configuration file (config/database.yml) with your local database credentials.

  4. Run database migrations: rails db:{drop,create,migrate,seed}

  5. Execute the RSpec command to run the tests: bundle exec rspec

  6. Start the server: rails server

You can now make requests to http://localhost:3000/graphql and interact with the PackMate backend locally.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

(back to top)

Releases

No releases published

Packages

No packages published

Languages