@here anyone know how we can filter results by an ...
# prisma-whats-new
k
@here anyone know how we can filter results by an enum value. the normal filter is not letting me use my enum.
a
Why not?
f
Dont know if it helps, but here is a complex filter example on ENUM
Copy code
query {
allInfluencers(filter: {myNetworkPlatforms_some: {network: TWITTER}}) {
myNetworkPlatforms (filter: { network: TWITTER }) {
link
network
networkUsername
}
}
}
👍🏻 1
Twitter being an ENUM in this case
a
I suspect you are passing in the enum value as string (so quoted). The example shows the right way.
salute 1
k
{ allArtists(filter: {genre: Rock }){ id name } }
this is my query
and the error:
"message": "Argument 'filter' expected type 'ArtistFilter' but got: {genre: Rock}. Reason: 'genre' Field 'genre' is not defined in the input type 'ArtistFilter'. (line 2, column 22):\n allArtists(filter: {genre: Rock }){\n ^\n (line 2, column 23):\n allArtists(filter: {genre: Rock }){\n ^",
sorry about no snippets, slack isnt giving me an option 😬
f
try genre_all
if you search the schema in console for genre, you will get the types available for filter
itll be something like genre_some, genre_none
k
its strange, every other attribute in my type is available to filter just not genre
not getting autocompletion for anything starting with genre in graphQL Playground. very strange
f
Under ENUMS .. is there a enum genre (
itll usually be upper case first char as well
enum Genre
k
yeah thats there
f
try upper casing the value
Genre
also make sure your statement starts with
query { allArtists(filter: {genre: Rock }){ id name } }
k
still no luck, very strange as its the only filter not possible, however it is the only enum in that type
ahh, my attribute using the enum allows an array of the enum not a single value, that may be the problem
👍 1
f
}yeah enums and arrays do not play
k
Yeah, problem avoided, cheers for the help 😀
salute 1