What I want to avoid is writing a bunch of mutatio...
# prisma-whats-new
g
What I want to avoid is writing a bunch of mutations to update one filed at a time.
👍 1
l
You’ll want to make sure the data is sanitized, but this is where your spread operator is magic. ‘...args’
b
@harmony
h
@gihrig pass the data object from the client
j
do you have an example I can see of this
g
@justinrich This is a work in progress, seems to work. Here’s snippets of what I have so far.
Copy code
async updateItem(parent, args, ctx, info) {
// Exclude id from data
const { id, ...data } = args
    return ctx.db.mutation.updateItem(
      {
        where: { id },
        data
      },
      info,
    )
See here for more code detail: https://graphcool.slack.com/archives/C0MQJ62NL/p1520463505000122 Thanks to @lawjolla and @harmony for getting me started in the right direction 🙂
👍 2
h
I just have
updateMote(moteId: ID!, update: MoteUpdateInput!): Mote!