I’m trying to create a GraphQL query that makes a fuzzy search, but it just returns an empty array. I have tried many different ways, but the documentation isn’t helping. I don’t get it, aren’t you supposed to do it like this or why is it so hard?
Here is my GraphQL query:
type Query {
querySearchRooms(SEARCH: String!): [Room] @custom(dql: """
query q ($SEARCH: string) {
querySearchRooms (func: match(name, $SEARCH, 3)) {
id
}
}""")
}
The “Room”-type looks like this:
type Room {
id: ID!
name: String! @id @search(by: [trigram])
}
Valdanito
(Valdanito)
September 9, 2021, 2:34am
2
Change id
to Room.id
, name
to Room.name
in your dql.
I updated it and it still returns an empty array.
type Query {
searchRoom(search: String!): [Room]
@custom(
dql: """
query q ($search: string){
searchRoom(func: match(Room.name, $search, 3)) {
Room.id
}
}"""
)
}
Nope, still the empty array.
type Query {
searchRoom(search: String!): [Room]
@custom(
dql: """
query q ($search: string){
searchRoom(func: match(Room.name, $search, 3)) {
Room.uid
}
}"""
)
}
Valdanito
(Valdanito)
September 10, 2021, 9:21am
7
I see, you should use alias.
type Query {
searchRoom(search: String!): [Room]
@custom(
dql: """
query q ($search: string){
searchRoom(func: match(Room.name, $search, 3)) {
id:uid
name:Room.name
}
}"""
)
}
2 Likes