How to handle case sensitivity in a Prisma query?

prisma

#1

I have a User.email field that contains the value Bob@bob.com

I would like the user query to match bob@bob.com but querying on this value returns no results and I can’t figure out where I should do this or if it is possible with Prisma. Is this a TypeScript or Prisma issue?

Also, could someone point me to resources where I could learn about how to use the query command? eg: ctx.db.query.user({ where: { email } } )

# datamodel.graphql

type User {
  id: ID! @unique
  email: String! @unique
  password: String!
  name: String!
  posts: [Post!]!
  products: [Product!]!
}
# schema.graphql

type User {
  id: ID!
  email: String!
  name: String!
  posts: [Post!]!
}
// resolvers>Mutation>auth.ts
...
async login(parent, { email, password }, ctx: Context, info) {
    email = email.toLowerCase();

    const user = await ctx.db.query.user({ where: { email } })
...

#2

I suggest making sure in your mutation resolvers that all emails you enter to Prisma lower cased.
Then you can also filter for the lower cased email in your query.

Do you have more specific questions?

By the way, I improved the formatting of your post, so it’s easier to read :slight_smile: