brandon
07/25/2018, 4:42 PMlawjolla
07/25/2018, 4:51 PMgoToApi: async (_, args, ctx, info) => {
const transaction = await ctx.db.mutation.createTransaction(data: {... })
const api = await fetch(`third party`)
if (!validated api) ctx.db.mutation.deleteTransaction(where: { id: transaction.id })
else ctx.db.mutation.updateTransaction(where: {id: transaction.id}, data: {... api.data}})
}
brandon
07/25/2018, 4:53 PMbrandon
07/25/2018, 4:53 PMlawjolla
07/25/2018, 4:58 PMbrandon
07/25/2018, 4:58 PMlawjolla
07/25/2018, 4:58 PMbrandon
07/25/2018, 4:58 PMlawjolla
07/25/2018, 5:00 PMtype Transaction {
...
uuid: ID! @unique
}
Basically, it's a server generated unique ID. So you can later query by its actual ID or its UUID. This is a good pattern for keeping track of things on the client without getting the server id back. The client generates a uuid and can then query the database with that uuid instead of getting the server idbrandon
07/25/2018, 5:00 PMbrandon
07/25/2018, 5:01 PMbrandon
07/25/2018, 5:01 PMbrandon
07/25/2018, 5:02 PMlawjolla
07/25/2018, 5:02 PMbrandon
07/25/2018, 5:03 PMlawjolla
07/25/2018, 5:03 PMlawjolla
07/25/2018, 5:05 PMgoToApi: async (_, args, ctx, info) => {
const transactionUUID = uuid()
const api = await fetch(`third party`, transactionUUID)
if (validated api) ctx.db.mutation.createTransaction(data: { uuid: transactionUUID, ...api.data })
}
lawjolla
07/25/2018, 5:06 PMbrandon
07/25/2018, 5:06 PMlawjolla
07/25/2018, 5:07 PMbrandon
07/25/2018, 5:07 PMbrandon
07/25/2018, 5:07 PM