Skip to content

Commit

Permalink
feat(TransactionQuery): Use transaction reference input as query argu…
Browse files Browse the repository at this point in the history
…ment (#10087)
  • Loading branch information
gustavlrsn committed May 7, 2024
1 parent 58aecf5 commit 1852984
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 15 deletions.
71 changes: 58 additions & 13 deletions server/graphql/schemaV2.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3211,6 +3211,11 @@ type LegalDocument {
"""
service: LegalDocumentService!

"""
Whether this legal document is expired
"""
isExpired: Boolean!

"""
The date and time the request for this legal document was created
"""
Expand Down Expand Up @@ -6132,10 +6137,20 @@ type HostApplication {
"""
account: Account!

"""
The host the collective applied to
"""
host: Host!

"""
The date on which the item was created
"""
createdAt: DateTime!

"""
The date on which the item was updated
"""
updatedAt: DateTime!
status: HostApplicationStatus
message: String
customData: JSON
Expand Down Expand Up @@ -8393,6 +8408,11 @@ type Collective implements Account & AccountWithHost & AccountWithContributions
"""
hostFeePercent(paymentMethodService: PaymentMethodService, paymentMethodType: PaymentMethodType): Float

"""
Returns the Fiscal Host application
"""
hostApplication: HostApplication

"""
How much platform fees are charged for this account
"""
Expand Down Expand Up @@ -8496,6 +8516,11 @@ interface AccountWithHost {
"""
hostFeePercent(paymentMethodService: PaymentMethodService, paymentMethodType: PaymentMethodType): Float

"""
Returns the Fiscal Host application
"""
hostApplication: HostApplication

"""
Fees percentage that the platform takes for this collective
"""
Expand Down Expand Up @@ -9574,6 +9599,11 @@ type Event implements Account & AccountWithHost & AccountWithContributions & Acc
"""
hostFeePercent(paymentMethodService: PaymentMethodService, paymentMethodType: PaymentMethodType): Float

"""
Returns the Fiscal Host application
"""
hostApplication: HostApplication

"""
How much platform fees are charged for this account
"""
Expand Down Expand Up @@ -13160,7 +13190,12 @@ type Query {
"""
The public id identifying the transaction (ie: rvelja97-pkzqbgq7-bbzyx6wd-50o8n4rm)
"""
id: String
id: String @deprecated(reason: "2024-05-07: Please use the `transaction` field.")

"""
Identifiers to retrieve the transaction.
"""
transaction: TransactionReferenceInput
): Transaction
transactions(
"""
Expand Down Expand Up @@ -15617,6 +15652,11 @@ type Fund implements Account & AccountWithHost & AccountWithContributions {
"""
hostFeePercent(paymentMethodService: PaymentMethodService, paymentMethodType: PaymentMethodType): Float

"""
Returns the Fiscal Host application
"""
hostApplication: HostApplication

"""
How much platform fees are charged for this account
"""
Expand Down Expand Up @@ -16465,6 +16505,11 @@ type Project implements Account & AccountWithHost & AccountWithContributions & A
"""
hostFeePercent(paymentMethodService: PaymentMethodService, paymentMethodType: PaymentMethodType): Float

"""
Returns the Fiscal Host application
"""
hostApplication: HostApplication

"""
How much platform fees are charged for this account
"""
Expand Down Expand Up @@ -16571,6 +16616,18 @@ input TierReferenceInput {
isCustom: Boolean
}

input TransactionReferenceInput {
"""
The public id identifying the transaction (ie: dgm9bnk8-0437xqry-ejpvzeol-jdayw5re)
"""
id: String

"""
The internal id of the transaction (ie: 580)
"""
legacyId: Int
}

"""
A PayPal plan to associate with a contribution
"""
Expand Down Expand Up @@ -19981,18 +20038,6 @@ type BanAccountResponse {
accounts: [Account!]!
}

input TransactionReferenceInput {
"""
The public id identifying the transaction (ie: dgm9bnk8-0437xqry-ejpvzeol-jdayw5re)
"""
id: String

"""
The internal id of the transaction (ie: 580)
"""
legacyId: Int
}

"""
Input type for UpdateType
"""
Expand Down
12 changes: 10 additions & 2 deletions server/graphql/v2/query/TransactionQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { GraphQLString } from 'graphql';

import models from '../../../models';
import { NotFound } from '../../errors';
import { fetchTransactionWithReference, GraphQLTransactionReferenceInput } from '../input/TransactionReferenceInput';
import { GraphQLTransaction } from '../interface/Transaction';

const TransactionQuery = {
Expand All @@ -11,11 +12,18 @@ const TransactionQuery = {
id: {
type: GraphQLString,
description: 'The public id identifying the transaction (ie: rvelja97-pkzqbgq7-bbzyx6wd-50o8n4rm)',
deprecationReason: '2024-05-07: Please use the `transaction` field.',
},
transaction: {
type: GraphQLTransactionReferenceInput,
description: 'Identifiers to retrieve the transaction.',
},
},
async resolve(_, args) {
async resolve(_, args, req) {
let transaction;
if (args.id) {
if (args.transaction) {
transaction = await fetchTransactionWithReference(args.transaction, req);
} else if (args.id) {
transaction = await models.Transaction.findOne({ where: { uuid: args.id } });
} else {
return new Error('Please provide an id');
Expand Down

0 comments on commit 1852984

Please sign in to comment.