You can do search-like queries using the prisma client. Here is an example of an auto-generated interface for the where
query parameter of a User entity in one of my apps.
export interface UserWhereInput {
name?: String;
name_not?: String;
name_in?: String[] | String;
name_not_in?: String[] | String;
name_lt?: String;
name_lte?: String;
name_gt?: String;
name_gte?: String;
name_contains?: String;
name_not_contains?: String;
name_starts_with?: String;
name_not_starts_with?: String;
name_ends_with?: String;
name_not_ends_with?: String;
...
AND?: UserWhereInput[] | UserWhereInput;
}
Note name_contains
and name_starts_with
. These are both valid to use for a simple search, here's an example resolver -
const userSearchResolver = async (_root, _args, _context) => {
return await _context.prisma.users({
where: {
name_starts_with: _args.searchQuery
}
});
}
);