Skip to content

karatekaneen/stockyGQL

Repository files navigation

Table of Contents

createGetStockList

Factory function for the getStockList resolver.

Parameters

  • getFields Function To extract what fields requested in the query (optional, default require('../helpers/fieldsHelper').getFields)
  • DatabaseWrapper Class To handle all the db functions (optional, default require('../../database/DatabaseWrapper'))
  • searchStocks Function To filter all the stocks by the args provided. (optional, default require('../helpers/stockSearcher').searchStocks)

Returns Function getStockList

createGetSingleStock

Factory function for getSingleStock

Parameters

  • getFields Function To extract what fields requested in the query (optional, default require('../helpers/fieldsHelper').getFields)
  • DatabaseWrapper Class To handle all the db functions (optional, default require('../../database/DatabaseWrapper'))

Returns Function getSingleStock

getStockList

Resolver function to get list of stocks. Searches by all the parameters given and fetches only the fields needed to minimize data usage.

Parameters

  • root Object
  • args Object Arguments provided in the query
  • context Object
  • info Object Information about the fields requested etc.

Returns Array<Object> List of stocks

getSingleStock

Resolve function to get a single stock with the fields specified in the query.

Parameters

  • root Object
  • args Object Arguments provided with the query
    • args.id number Id of the stock to get
  • context Object
  • info Object Information about the fields requested etc.

getFields

Helper function to extract the fields requested in a query

Parameters

  • info Object the info object that gets passed to the resolver

DatabaseWrapper

Wrapper for database functions

Parameters

  • Firestore Class The Firestore library (optional, default require('@google-cloud/firestore'))
  • secrets Object Credentials to Firestore (optional, default require('../../secrets.json'))

getSummary

Gets the summary document from the database with info such as name and list of each stock.

Returns Object Object with information about each stock

getAllStocks

Fetches all the stocks and the fields specified. If no fields are specified all will be fetched.

Parameters

  • fields Array<String> The fields that should be fetched from the database (optional, default [])

getByIds

Fetches stocks by Id and the fields specified. If no fields are specified all will be fetched.

Parameters

  • idsToGet Array<Number>
  • fields Array<String> The fields that should be fetched from the database (optional, default [])

getSingleById

Fetches single stock by id from the database with the fields provided.

Parameters

Returns Object A single stock

searchStocks

Function to filter down a list of stocks by the arguments passed to the query. It uses the AND operator, ie. that if both name and list is provided both args must match.

Parameters

  • args Object
    • args.id Array<Number> Optional array of ids
    • args.name String String to search for in the name of the stock
    • args.list String String to search for in the list of the stock
  • stocks Array<Object> List of stocks to search in

Returns Array<Number> Ids of the stocks to fetch

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published