Skip to content

doohinkus/cascade-graphQl-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HVAC GraphQl Api Project in Progress

Build Status

Stack used:

  • GraphQl / Apollo Server / Apollo Client
  • MongoDb
  • React
  • Docker
  • React Testing Library / Apollo Client Testing

Mongo is hosted on MongoDB Atlas Cloud

I removed the docker mongo dependency. The data is hosted on remote mongo cloud server. Here are the updated directions.

Step 1 Run Apollo

apollo-server

npm install

Step 2 Run Apollo / Play with Queries

Change directories into apollo-server

apollo-server

npm run serve

This will launch apollo server. There should be a success message in the console.

You can use the apollo query tool to view results: http://localhost:4000

Graphql

A few queries to try:

   query {
        HVACRange(startDate: "06/01/2020", endDate: "07/31/2020", type: "AC"){
          Date
          hasTriggeredHeater
          hasTriggeredAC
          HVACEventsCount
        }
      }

The query above shows results for AC events. You can add or remove fields. For instance, you can remove hasTriggeredHeater as a result, that field will not be present in the json response. Other avialable fields should auto suggest.

Note: HVACEventsCount shows all AC events for the date range--that is why the number is high--it's activations by the hour. HVACRangeCount is the count requested in the challenge. It counts the days the HVAC was on at least once.

Step 4 Run Client

With apollo and mongo running, change directories into client. Run the following command to install node_modules.

client

npm install

After installing node_modules, run this command

npm start

The client will launch here: http://localhost:3000

I have written some code to show the dates in the UI--but it's commented out. My idea was to show the dates, and then let the user click on the date, a modal would show the HVAC details for that date (details page). I decided to focus more effort on Graphql because UI was extra. As a result, the queries and resolvers are written for the feature--but the UI is not.

Todo:

  • More Unit Tests -- there are very few in the UI. 100% unit test converage client
npm run test:cov
  • Improve data seeding
  • CI/CD process (Would like to dockerize run the project in ngnix) Added git ci test hook and travis ci test results. Still need to add nginx.
  • UI, including basic date Refactoring UI - greyframe
  • SECURITY -- Removed the info in .env. Project will no longer work in local because the connection to the cloud db is no longer present.

About

GraphQl Api for Cascade Energy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published