Invalid Prisma invocation

Hello here,

I’m trying redwoodjs and so far I like it quite much.
I’m having issues though with custom reducers & graphql queries.

The goal is to retrieve the configuration field from the User table based on a uid field ( not the default id), here’s the related schema:

type User {
    id: String!
    uid: String!
    createdAt: DateTime!
    updatedAt: DateTime
    handle: String!
    email: String!
    lastname: String!
    firstname: String!
    localisations: Localisation
    collections: Collection
    configuration: String

  type UserConfiguration {
    handle: String!
    configuration: String!

  type Query {
    users: [User]
    user(id: String!): User
    userConfiguration(uid: String!): UserConfiguration

Here’s the reducer in the related api/services/user/user.js:

export const userConfiguration = ({ uid }) => db.user.findOne({ where: { uid } })

Now this is the query on the client side:

query UserConfiguration($uid: String!) {
    userConfiguration: userConfiguration(uid: $uid) {

And finally, here comes the error message:

Where does the UserWhereUniqueInput comes from?
From my research it’s from Prisma but I don’t understand how it is composed and why it is used.

How are selected the limited authorized parameters, id, handle & email?

What have I missed to implement this different query?


Did you mark the uid field as @unique in schema.prisma? It seems like you did do this with email and handle?

For now findOne can only be used with unique identifiers. I believe prisma is changing this tho to make findOne more flexible like findMany


Hello @Robert,

Many thanks, that was it indeed.
I’d appreciate prisma’s efforts for a bit more flexibility, however it does make some sense to have it work that way: I should have set uid as @unique to begin with - it’s an id field, and findOne would suggest it works only with @unique fields.

Thanks again! It had bugged me for some time.