Hey guys, I would really like to refer to my quest...
# orm-help
e
Hey guys, I would really like to refer to my question over here in order to get help. I hope this is ok: https://prisma.slack.com/archives/CCWDULGUW/p1537708380000100
r
The problem is the way in which you are connecting permissions in
createRole
mutation.
connect
expects an array of object with
id
as key instead of array of values. Changing your mutation code to something like below should get it to working for you:
Copy code
createRole(root, args, context) {
            return context.prisma.createRole(
                {
                    title: args.title,
                    permissions: {
                        connect: args.permissions.map((permission) => ({id: permission}))
                    }
                }
            )
        },
e
Thanks a lot! @Raeesaa
👍 1
Is there also a way to have certain amount of data built into the database without having to create them first? @Raeesaa I couldn't find any reference about that as well in the documentation
e
@Raeesaa Thank you a lot again!
@Raeesaa Do you know what it is not possible to use ENUMS in mutations? I always get "Cannot return null for non-nullable field Permission.title."
r
It is possible to use enums in mutation. We do that. But I don't see enums in code you posted above. Also, are you getting null value related error for createRole mutation?
e
No I am getting an error for createPermission mutation
That's the code:
schema.graphql
Copy code
enum PermissionEnum {
    Create,
    Delete
}
Copy code
type Permission {
    id: ID!
    title: PermissionEnum!
}
Mutation:
Copy code
createPermission(
        title: PermissionEnum!
    ): Permission
Resolver
Copy code
createPermission(root, args, context) {

            console.log(`This is the permissionEnum: ${args.title}`)
            return context.prisma.createPermission(
                {
                    title: args.title
                },
            )
        },
@Raeesaa
@Raeesaa weird, isn't it?
r
Yes, this looks weird.