GithubHelp home page GithubHelp logo

take-home-assignment-graphql-simplyrets-db's Introduction

Please read the PLEASE_READ_FIRST.md first. โœ…

Please document your code & design decisions here. โœ…

What's included

  • New GraphQL mutation that increments the favorite counter of a property.

    Note: it is by design that I'm not validating if the property exists previously to increment the counter.

  • New GraphQL query to list properties from SimplyRETS API + the count of favorite stored on Mongo.
  • Added Bearer HTTP Authentication to restrict access to all GraphQL endpoints using Apollo context definition.
  • Unit Test for every method.

What's not included

  • In order to keep the project simple, usernames and password to access SimpleRest are located in src/constants.js file in plain text.

Architecture design

  • Every GraphQL API its implemented in src/controller.js file. The controller has the business logic to retrieve the information that needs, and what to do with it.
  • Every model encapsulates the mechanism to access its data, for example, database entities like users and favorites implement methods to read and write to mongoDb.
  • In a simmilar way, all operations related Properties are under src/listings.js to hide the implementaion aspect of where and how to retreive information about properties via SimpleREST apis.

Challenges

  • MongoDB: I was not familiarized with mongoDb operations. For example, when increasing the favorite count of a property, my initial though was to search by ID, if the records is found, increase the count with an Update operation, if the record is not present use the Insert operation. Instead I learned that I could use the "upsert" option to to perform the search + insert|update in single atomic command.
  • Unit Test: it took me some time mock mongodb when writting test for those entities that required access to mongoDb. Searching online pointed me to use localmongo to seed my test db, instead I choose to use jest.mock to validate what apis were used, what arguments passed and control the output.

Notes

  • Dependencies hasn't been upgraded.
  • axios has been included as dependency to access simpleRest APIs.

take-home-assignment-graphql-simplyrets-db's People

Contributors

renovate[bot] avatar dependabot[bot] avatar acspock avatar dbaq avatar prescottprue avatar

Watchers

Leandro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.