Text Searching in a tenancy environment?

How do you use the search api in a tenancy environment. eg. I want to provide a "contains" type of text search on shopifyProduct but I do not want to return all results across multiple shops. The search docs https://docs.gadget.dev/api/example-app/development/sorting-and-filtering#searching say I can't use this while also filtering. Is there anyway to work around this?
7 Replies
Chocci_Milk
Chocci_Milk2w ago
Hello, Could you please explain what you mean by "in a tenancy environment"? Are you making the request from the backend (system-admin role) or from the frontend?
Leddo
LeddoOP2w ago
for example. On the front end app, I want to provide a way a customer can search the shopifyProduct description looking for products that contain their phrase. But as shopifyProduct contains all products from all installed shops, I also need to filter by shop, right? otherwise I would get all matching products from all shops back?
Chocci_Milk
Chocci_Milk2w ago
Tenancy will already be applied to the search from the frontend. This is because of the Gelly filter on the read permission of the shopifyProduct model Have a look at these docs to get a further explanation of how that works: https://docs.gadget.dev/guides/access-control#access-control https://docs.gadget.dev/guides/plugins/shopify/advanced-topics/customer-account-ui-extensions#adding-a-tenancy-filter
Leddo
LeddoOP2w ago
oh, I didn't realize that applied to the search automatically. let me try that.
Chocci_Milk
Chocci_Milk2w ago
Note that the tenancy filter only gets applied on requests from the frontend
Leddo
LeddoOP2w ago
ok thanks. appreciate your help.
airhorns
airhorns2w ago
and searching and filtering are possible to do together at the same time, just not when filtering across relationships right now but you can definitely search and filter simultaneously on the same model

Did you find this page helpful?