Sacha Weatherstone
04/08/2020, 11:13 PMmodel User {
id String @id @default(cuid())
username String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
groups Group[]
}
enum Group {
ADMIN
RADIUS
}
I am able to assign multiple enum values to a user using the api or studio, however I am unsure of how to handle this in nexus.
Seems as though I need a definition for Group, but don't know what fields I need.luhagel
04/09/2020, 3:08 AMset field, e.g.
prisma.user.create({
data: {
// Rest
groups: { set: ['ADMIN', 'OTHER'] }
}
})luhagel
04/09/2020, 3:10 AMset in an update, all the previpous roles will be overriddenSacha Weatherstone
04/09/2020, 3:10 AMimport { schema } from 'nexus'
schema.objectType({
name: 'Group',
definition(t) {
t.model...
},
})Sacha Weatherstone
04/09/2020, 3:11 AMluhagel
04/09/2020, 3:12 AMschema.enumType()Sacha Weatherstone
04/09/2020, 4:02 AMschema.enumType({
name: 'Group',
members: {
ADMIN: String,
RADIUS: String,
},
})
but upon querying I get Expected a value of type \"Group\" but received: \"ADMIN\"luhagel
04/09/2020, 4:04 AMSacha Weatherstone
04/09/2020, 4:04 AMSacha Weatherstone
04/09/2020, 4:05 AMSacha Weatherstone
04/09/2020, 4:05 AMschema.enumType({
name: 'Group',
members: ['ADMIN', 'RADIUS'],
})Sacha Weatherstone
04/09/2020, 4:06 AMluhagel
04/09/2020, 4:06 AMSacha Weatherstone
04/09/2020, 4:06 AMluhagel
04/09/2020, 4:06 AMSacha Weatherstone
04/09/2020, 4:06 AM