Ricardo Alvarado
Ricardo Alvarado

Reputation: 89

Filter by Email in prisma GraphQL

I'm trying to filter a user by email, I am using prisma and doing tests with the "playground", is there any way to filter the user's data by email?

My schema:

interface Model {
  id: ID! @id
  createdAt: DateTime! @createdAt
  updatedAt: DateTime! @updatedAt
}

type User implements Model {
  id: ID! @id
  createdAt: DateTime! @createdAt
  updatedAt: DateTime! @updatedAt
  username: String
  name: String!
  surname: String!
  email: String!
  token_usuario: String! @unique
}

My attempts:

enter image description here

enter image description here

Upvotes: 1

Views: 875

Answers (1)

TLadd
TLadd

Reputation: 6884

Using prisma 2.0, the db client exposes something like this:

ctx.prisma.user.findMany({
  where: {
    email: { contains: "something" }
  }
});

And I expect the query would follow suit. So try passing in the where field for filtering. Would need to see the full schema to say for sure.

Upvotes: 1

Related Questions