Open dkozma opened 4 years ago
It also seems like the solution proposed in #584 would also help with providing a way for resolving this issue if there is no built-in functionality available at the moment.
I would be interested in something like this:
schema.mutationType({
definition(t) {
t.field(t.crud.createOneUser.fieldName, {
type: t.crud.createOneUser.type,
args: t.crud.createOneUser.args,
resolve: t.crud.createOneUser.resolve,
});
},
});
this way you could customize the args (or other properties for that matter) pretty easily
_.pick(t.crud.createOneUser.args, ['whatever', 'columns', 'i', 'want']);
const {columnIWantToExclude, ...rest} = t.crud.createOneUser.args;
const args = {
...rest,
someAdditionalInputField: stringArg(),
};
This may be related to #90, however the API has changed quite a bit since that conversation took place. Essentially what I would like is to be able to set certain fields as readonly if they should not be able to be updated by clients.
One of the things I've tried is using
computedInputs
to set the input for the protected field toundefined
, which properly removes it from the input and preserves the value, however it also has the unfortunate side-effect of not letting me use that field in thewhere
condition. For instance:results in a message such as:
when I submit mutation data such as:
I would also rather avoid duplicating all of my writable
User
fields into arguments in a customUpdateUser
mutation that callsctx.prisma.user.update()
. However, if that is the only way, I would be open to writing a conversion function for this as long as I could get a list of the fields in theUser
schema programmatically, so I don't have to keep multiple places updated in code.I would imagine this is a common use case, however the only examples I could find with modifying input were with create mutations. Is there something I am missing?
Edit: https://slack.prisma.io/ is now working for me.