Ghyath Darwish
Ghyath Darwish

Reputation: 2826

Prisma get data based on computed field

I need to get data depends on computed field For example

const resolvers = {
  Query: {
    users: (parent, args, ctx, info) => {
      const fragment = `fragment EnsureFullName on User { firstName lastName }`
      return ctx.db.query.users({}, addFragmentToInfo(info, fragment))
    },
  },
  User: {
    fullName: parent => `${parent.firstName} ${parent.lastName}`,
  },
}

I need to get all data where fullname = 'any value',

How can I do that ?

Upvotes: 5

Views: 1768

Answers (1)

realAlexBarge
realAlexBarge

Reputation: 1878

You need to filter manually after fetching from the database or use use a where condition to check if firstName and lastName:

const users = await prisma.users({ where: { firstName: 'any', lastName: 'value' } });

Upvotes: 1

Related Questions