Skip to content

Building habits bit by bit (with Ruby on Rails, React, and Graphql)

Notifications You must be signed in to change notification settings

strativd/habits-on-rails

Repository files navigation

haBits logo
React logo Roby On Rails logo GraphQL logo

✅ haBits — building habits, bit by bit.

A personal web project to practice React, GraphQL, Ruby on Rails, and good habits...

haBits habit tracking screenshot

Getting started

$ git clone https://github.com/ztratify/habits (or similar) to clone the repo locally

$ cd habits to open the project

$ bundle install to download ruby gems

Errors? Make sure you install Ruby on Rails first...

ruby '2.6.3'

rails '6.0.3'

$ yarn install to download node dependencies

$ rails db:create && rails db:migrate && rails db:seed to build a local database and seed it with data

Errors? Make sure you install MySQL database first...

$ brew install [email protected] and address any "Caveats" messages

$ brew services start [email protected] to run mysql locally

$ rails s to start the server and web app!

Finally visit http://localhost:3333 to start building habits!

GraphQL

Explore GraphQL Schema using graphiql interface: http://localhost:3333/graphiql

Queries

Habits & Steps with custom search, filtering and sort:

query habitsAndSteps {
  habits (
    order: CREATED
    search: "WATER"
  ) {
    id
    title
    goal
    period
    slug
    steps (
      order: DATE
      startDate: "2021-11-11"
      endDate: "2021-11-13"
    ) {
      goal
      progress
      isComplete
    }
  }
}

Mutations

Create Habit:

mutation createHabit {
  createHabit(input:{
    title: "💦 FILL WATER BOTTLE",
    goal: 3,
    period: "daily"
  }) {
    habit {
      id
      title
      slug
      createdAt
    }
  }
}

Update Habit:

mutation updateHabit {
  updateHabit(input:{
    id: 11,
    title: "👨‍💻 15 MINUTES OF CODE",
    goal: 3,
  }) {
    habit {
      goal
      title
      period
      slug
      id
    }
  }
}

Delete Habit:

mutation deleteHabit {
  deleteHabit(input:{
    id: 11
  }) {
    habit {
      id
      slug
    }
  }
}

Create Habit Steps (progress):

mutation createSteps {
  createSteps(input:{
    habitId: 11,
    date: "2021-11-11",
    progress: 3,
  }) {
    step {
      date
      goal
      progress
      isComplete
      habit {
        title
        goal
      }
    }
  }
}

Update Habit Steps (record progress):

mutation updateSteps {
  updateSteps(input:{
    habitId: 11,
    date: "2021-11-11",
    progress: 1,
  }) {
    step {
      date
      goal
      progress
      isComplete
      habit {
        title
        goal
      }
    }
  }
}

TODO (update with):

This README would normally document whatever steps are necessary to get the application up and running.

Things you may want to cover:

  • Ruby version

  • System dependencies

  • Configuration

  • Database creation

  • Database initialization

  • How to run the test suite

  • Services (job queues, cache servers, search engines, etc.)

  • Deployment instructions

  • ...

About

Building habits bit by bit (with Ruby on Rails, React, and Graphql)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published