Register a transaction
Learn how to register a transaction on behalf of a user, you will need to:
createTransaction
Use the createTransaction function and include the necessary parameters.
export const createTransaction = extendType({
type: "Mutation",
definition(t) {
t.field("createTransaction", {
type: CreateTransactionPayload,
args: {
input: arg({
type: inputObjectType({
name: "CreateTransactionInput",
description: "Input parameters for creating a transaction.",
definition(t) {
t.nonNull.string("amount", {
description: "TBD",
});
},
}),
}),
},
resolve: async (parent, { input }, ctx) => {
return {
transaction: {
id: "1234",
active: true,
},
};
},
});
},
});
commitTransaction
Use the commitTransaction function to finalize the transaction.
export const commitTransaction = extendType({
type: "Mutation",
definition(t) {
t.field("commitTransaction", {
type: CommitTransactionPayload,
args: {
input: arg({
type: inputObjectType({
name: "CommitTransactionInput",
description: "Input parameters for committing a transaction.",
definition(t) {
t.nonNull.string("token", {
description: "TBD",
});
t.nonNull.string("userId", {
description: "TBD",
});
},
}),
}),
},
resolve: async (parent, { input }, ctx) => {
return {
transaction: {
id: "1234",
active: true,
},
};
},
});
},
});
After these steps have been completed, a new transaction will have been created.
Last updated on December 30, 2022