Created
April 5, 2018 22:59
-
-
Save doug2k1/d70ce1f77527ac8ba8bd76ee9ff597d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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