Hi guys! I might have a very dumb question... Cons...
# prisma-whats-new
m
Hi guys! I might have a very dumb question... Considering I have an enum in my schema, how do I (with yoga) write my where condition with the value? String is not working as like in the playground
Copy code
enum ADDRESS_TYPE {
    WORK
    HOME
    OTHER
}
Copy code
const where = {
        type: HOME, // Not working
      }
  
      return ctx.db.query.addresses({ where }, info)
l
That's a gotcha. In the Playground it's not a string, in everything else it is a string
where = { type: "HOME" }
m
thanks @lawjolla but I got a
Can't assign the type 'string' to type 'ADDRESS_TYPE'.
This is the first thing I tried since it is working for a mutation
l
Then your schema isn't defined correctly
Check how you've defined
type
m
I'm not that sure... Took an example from a working mutation I had and wrote a simple query. Here is the result http://jmp.sh/RrHHj79
l
I maintain my previous statement but without a schema it's impossible to say
m
@lawjolla I'll admit this is weird, I'm struggling with this for the last hour. I checked the
ParticipantWhereInput
and
ParticipantCreateInput
and they both reference PARTICIPATION_STATUS
Copy code
type Participant {
  id: ID! @unique
  moment: Moment
  user: User!
  status: PARTICIPATION_STATUS! @default(value: NOT_ANSWERED)
  reason: String
}
Copy code
enum PARTICIPATION_STATUS {
    YES
    NO
    MAYBE
    WATCHING
    NOT_ANSWERED
}
l
Sweet, give me one second
db.query.participants({ where: { status: "YES" } }, info)
returns what?
m
@lawjolla it is working 😄 never thought to try that. What the hell
l
What was different?
m
Just not creating a where object
If anyone comes here. @lawjolla answer works or you need to use
as
Copy code
const where = {
        isPublished: false,
        type: "EVENT" as MOMENT_TYPE,
        creator: {
          id
        }
      }
This is probably related to duck typing with Typescript
👍 1