I have an Advertiser
graphql type:
type Advertiser {
createdAt: DateTime!
id: Int!
isActive: Boolean!
name: String!
updatedAt: DateTime
}
Given the following mutation:
mutationType({
definition(t) {
t.crud.createOneAdvertiser();
}
});
Nexus generates this schema (as expected):
input AdvertiserCreateInput {
createdAt: DateTime!
isActive: Boolean!
name: String!
updatedAt: DateTime
}
type Mutation {
createOneAdvertiser(data: AdvertiserCreateInput!): Advertiser!
}
The thing is, what if I want to omit some of the args? For example, I don't want the client to pass createdAt
or updatedAt
. these columns should be resolved in the server.
See (partial) documentation here - https://nexusjs.org/docs/plugins/prisma/api#example-4
Yet again, found the answer right after posting this question. Simply pass computedInputs like so:
t.crud.createOneAdvertiser({
computedInputs: {
createdAt: () => DateTime.utc().toString(),
updatedAt: () => null
}
});