Frigo
12/05/2018, 7:04 PMtype Offer
that is in a one-many relation with Event
. I try to write a query that gives me all the offers that have no `Event`s and I thought this is an obvious use case, but for the life of me I cannot find a solution other than selecting every Offer
and filtering on the client. I found this (https://www.prisma.io/forum/t/filtering-out-data-based-on-whether-relations-exists/215), but based on my current prisma knowledge I have no idea what filter
is, in Playground it is not a valid syntax. How can this be done?Ivan Petrushev
12/06/2018, 6:00 AMPositionFilter
(which will be different on your schema). You can find it there in the Schema explorer and see exactly what fields it would accept.
Never did a query like yours, but probably I will have to do it one day, so I'm following this thread đIvan Petrushev
12/06/2018, 6:03 AMHotel
linked to Users
who own it):
{
allHotels(filter:{
owner: null
}){
id, title
owner {
id
}
}
}
Ivan Petrushev
12/06/2018, 6:03 AMIvan Petrushev
12/06/2018, 6:04 AMtype Hotel @model {
id: ID! @isUnique
title: String!
...
owner: User @relation(name: "HotelOwners")
}
Ivan Petrushev
12/06/2018, 6:15 AM{
allUsers(filter:{
hotels_every: {
id:"-1"
}
}){
id, email,
hotels{
id
}
}
}
more info here:
https://github.com/prisma/prisma/issues/1163
https://github.com/prisma/prisma/issues/110Frigo
12/06/2018, 10:12 PMfilter:
? For all the types i have a query (e.g. for type Offer
there is a query offers
that accepts following parameters where: OfferWhereInput
orderBy: OfferOrderByInput
skip: Int
after: String
before: String
first: Int
last: Int
The OfferWhereInput
has the usual id, id_not...
and for the fields and for relations events_some
, events_none
and events_every
. I donât see any filter anywhere đ.
Actually the â-1â using events_every
worked well, thanks!
And when I was about to continue happily coding I realised I need the exact opposite 𤌠I need every Offer
that has at least one Event
, BUT for that events_some: { id_not: null }
did the trick fast parrot
Thanks for your help!Ivan Petrushev
12/07/2018, 6:45 AMfilter
, I think you can read it here: https://www.graph.cool/docs/reference/graphql-api/query-api-nia9nushae search for "Fetch certain nodes of a specific type"Ivan Petrushev
12/07/2018, 6:46 AMallOffers
, you could check in the green Schema button on the right in the PlaygroundFrigo
12/07/2018, 11:58 AMfilter
and allOffers
is not familiar at all. In Prisma it is simply the plural form of the type name (so I guess Graphcoolâs allOffers
is Prismaâs offers
and filter
is where
)Ivan Petrushev
12/07/2018, 12:08 PM