I have the following schema coming out of nexus which is built from the prisma schema.
type Mutation {
createEvent(data: EventCreateInput!): Event!
}
input TennisTeam_EventCreateInput {
name: String!
owner: UserCreateOneWithoutEventsInput!
}
What I want to do is remove the owner argument from this type so it is not available when calling the mutation.
I have been trying to add the following but I don't know what syntax is required to remove the owner arg. The underlying prisma type has this but I want the server to set this value and not the client, thus removing the argument.
export const Mutation = prismaObjectType({
name: "Mutation",
definition(t) {
t.prismaFields([
{
name: "createEvent",
args: [???],
}
]);
}
});
Hey there,
You have to override the input type by doing the following:
export const YourInputType = prismaInputObjectType({
name: "YourInputType",
definition(t) {
t.prismaFields(['the field you want to keep', '...', ...])
}
});
Closing, feel free to re-open if that doesn't help you 馃檶
What if we want to make available some fields for an admin, for instance, and hide them for a user?
I have orders, which clients can rename, but they can't change the status of the order. And admins can do whatever they want on the order.
I would have two mutations, but I don't know how to "extend" or "restrict" an InputObjectType without overriding it. I would like to duplicate it with more or less arguments.
Is that possible?
@Weakky great, thanks! I think it should be in docs
Most helpful comment
Hey there,
You have to override the input type by doing the following:
Closing, feel free to re-open if that doesn't help you 馃檶