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
  • Loading branch information
gustavlrsn committed May 7, 2024
1 parent 58aecf5 commit 373a72c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 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,17 @@ const TransactionQuery = {
id: {
type: GraphQLString,
description: 'The public id identifying the transaction (ie: rvelja97-pkzqbgq7-bbzyx6wd-50o8n4rm)',
deprecationReason: '2024-05-07: Please use the `trannsaction` field.',
},
transaction: {
type: GraphQLTransactionReferenceInput,
},
},
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 373a72c

Please sign in to comment.