I’m having issues with graphql-yoga and prisma-bin...
# orm-help
j
I’m having issues with graphql-yoga and prisma-binding I’m trying to write the a resolver to retrieve all
Users
, I have this resolver:
Copy code
users: (_, args, context, info) => {
        console.log(info);
        return context.prisma.query.users({}, info);
    }
And when I hit the query I get this error:
Copy code
Cannot return null for non-nullable field User.name.
The query looks like this:
Copy code
{
  users {
    name
  }
}
Any idea on what I’m doing wrong?
m
What does your schema look like?
j
Copy code
# import User from './generated/prisma.graphql'

type Query {
    user(id: ID!): User
    users: User!
}
m
I think you want users to be an array, so:
Copy code
# import User from './generated/prisma.graphql'

type Query {
    user(id: ID!): User
    users: [User!]!
}
also, you might want your resolver to be async:
Copy code
users: async (_, args, context, info) => {
        console.log(info);
        return await context.prisma.query.users({}, info);
    }
j
It was the array thing, thank you so much, I’ll also add async syntax
👍 1