Current behavior
I've noticed that when I try to set a Scalar list [here, sugar] during an update mutation it does not "Override the existing list with an entirely new list." as mentioned here.
So, when I do something like so:
# Let's say, for simplicity that sugar === ["I don't know", "maybe", "perhaps", "who knows"]
# ...
data: {
sugar: { set: ["yes", "no"] || [] }
}
# ...
sugar [Scalar list of Strings] returns
sugar: ["yes", "no", "perhaps", "who knows"]
Reproduction
I currently have this type:
type Honeycomb {
id: ID! @unique
title: String!
hint: String
sugar: [String!]! @default(value: []) # represents possible answers
type: HONEYCOMB_TYPE!
hive: Hive!
}
And here's my mutation:
export const honeycomb = {
async updateHoneycomb(parent, args, ctx: Context, info) {
const beeKeeperId = getBeeKeeperId(ctx)
const { id, sugar, ...rest } = args
const foundHoneycomb = await ctx.db.exists.Honeycomb({
id,
hive: {
author: {
id: beeKeeperId,
},
},
})
if (!foundHoneycomb)
throw new Error(`Honeycomb not found or you're not the author`)
return ctx.db.mutation.updateHoneycomb(
{
where: { id },
data: {
...rest,
sugar: { set: sugar || [] },
},
},
info,
)
}
}
PS: If you have any comments on how I could make this mutation work with less lines of code, do tell ;)
Expected behavior?
I would expect sugar to return
sugar: ["yes", "no"]
instead of what I've described getting in the Current behavior report
Hey @speedtreammanga, thanks a lot for reporting this!
Your issue seems identical to this bug: https://github.com/graphcool/prisma/issues/1803, which was fixed in 1.1.3.
What is the version of your Prisma cluster?
@marktani Thanks for being so proactive!
$ prisma -v
prisma/1.0.7 (darwin-x64) node-v9.4.0
package.json
"devDependencies": {
//...
"prisma": "1.2.7"
}
Is that what you wanted ?
Hey @speedtreammanga, you shared the CLI version with me.
You can find out the cluster version using prisma cluster list. But given your CLI version, it looks like you are on an older version than 1.1.3 anyway 馃檪
So, upgrading your Prisma cluster should be the way to go here.
If you're using the CLI to manage the docker image, this is the way to do so:
npm install -g prisma
prisma local upgrade
It's recommend to export your data first, and doing this in a development or staging environment, to ensure the upgrade process goes smoothly 馃檪
If you have further questions about upgrading your cluster, I suggest starting a new discussion in the Forum.
Thanks!
@marktani Thanks, works like a charm!