Skip to content

Instantly share code, notes, and snippets.

@doug2k1
Created April 5, 2018 22:59
Show Gist options
  • Save doug2k1/d70ce1f77527ac8ba8bd76ee9ff597d3 to your computer and use it in GitHub Desktop.
Save doug2k1/d70ce1f77527ac8ba8bd76ee9ff597d3 to your computer and use it in GitHub Desktop.
const { GraphQLString } = require('graphql');
const { Broker, Investment, BalanceUpdate, Transaction } = require('../models');
module.exports = {
Query: {
brokers: (obj, args) => Broker.all(args),
broker: (obj, { id }) => Broker.findById(id),
investments: (obj, args) => Investment.all(args),
investment: (obj, { id }) => Investment.findById(id)
},
Investment: {
broker: obj => Broker.findOne({ where: { id: obj.BrokerId } }),
balanceUpdates: (obj, args) =>
BalanceUpdate.all({ where: { InvestmentId: obj.id }, ...args }),
transactions: obj => Transaction.all({ where: { InvestmentId: obj.id } })
},
Broker: {
investments: obj => Investment.findAll({ where: { BrokerId: obj.id } })
},
Date: GraphQLString
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment