Skip to content

Commit

Permalink
fetch allTransactions globally, fix default collective.isActive
Browse files Browse the repository at this point in the history
  • Loading branch information
xdamman committed Feb 21, 2018
1 parent 9f63398 commit 036ff10
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/graphql/TransactionInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const TransactionInterfaceType = new GraphQLInterfaceType({
platformFeeInHostCurrency: { type: GraphQLInt },
paymentProcessorFeeInHostCurrency: { type: GraphQLInt },
createdByUser: { type: UserType },
host: { type: UserCollectiveType },
host: { type: CollectiveInterfaceType },
paymentMethod: { type: PaymentMethodType },
fromCollective: { type: CollectiveInterfaceType },
collective: { type: CollectiveInterfaceType },
Expand Down
2 changes: 1 addition & 1 deletion server/graphql/mutations/collectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function createCollective(_, args, req) {
if (!hc) return Promise.reject(new Error(`Host collective with id ${args.collective.HostCollectiveId} not found`));
hostCollective = hc;
collectiveData.currency = collectiveData.currency || hc.currency;
if (req.remoteUser.hasRole([roles.ADMIN, roles.HOST, roles.MEMBER], hostCollective.id)) {
if (req.remoteUser.hasRole([roles.ADMIN, roles.HOST], hostCollective.id)) {
collectiveData.isActive = true;
}
})
Expand Down
11 changes: 8 additions & 3 deletions server/graphql/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,23 @@ const queries = {
allTransactions: {
type: new GraphQLList(TransactionInterfaceType),
args: {
CollectiveId: { type: new GraphQLNonNull(GraphQLInt) },
CollectiveId: { type: GraphQLInt },
collectiveSlug: { type: GraphQLString },
type: { type: GraphQLString },
limit: { type: GraphQLInt },
offset: { type: GraphQLInt },
dateFrom: { type: GraphQLString },
dateTo: { type: GraphQLString },
},
resolve(_, args) {
async resolve(_, args) {
const query = {
where: { CollectiveId: args.CollectiveId },
where: {},
order: [ ['createdAt', 'DESC'] ]
};

const CollectiveId = args.CollectiveId || await fetchCollectiveId(args.collectiveSlug);

if (CollectiveId) query.where.CollectiveId = CollectiveId;
if (args.type) query.where.type = args.type;
if (args.limit) query.limit = args.limit;
if (args.offset) query.offset = args.offset;
Expand Down

0 comments on commit 036ff10

Please sign in to comment.