Best way to skip tenant check on a query

In my app I have users and accounts. The accounts are tenants. Users have and belong to many accounts through memberships. I've made the memberships resource multi-tenant, but now the users can't load their memberships. Memberships are really co-owned. Should I remove the multi-tenancy? Or is there a way for a query to ignore the tenant check?
7 Replies
ZachDaniel
ZachDaniel3y ago
There are a few ways you could do it: 1. You could add global? true to the multitenancy config of memberships. That says "I can be queried with a tenant or without it" This won't really make sense if using schema-based multitenancy, but for attribute multitenancy it does. 2. this one depends, are the users not multi-tenant? If they were multitenant, and you specified a tenant when fetching them, then you should be able to load the memberships I think there might be some more options, but lets explore those first
Robert Graff
Robert GraffOP3y ago
Users are not multi-tenant since they can belong to multiple tenants at the same time Let me explore the global options. The documentation was a little vague on exactly the implications of the global option.
Whether or not the data also exists outside of each tenant. Defaults to false .
ZachDaniel
ZachDaniel3y ago
Are you using schema or attribute multitenancy
Robert Graff
Robert GraffOP3y ago
I'm using attribute
ZachDaniel
ZachDaniel3y ago
I'm thinking we may need to come up with an option just for this specifically, you have a non-tenant resource and you want tenanted relationships You could write a manual relationship potentially which even allows you to describe the join
Robert Graff
Robert GraffOP3y ago
Right now, global is working for me but it doesn't feel right.
ZachDaniel
ZachDaniel3y ago
Yeah, I think you need a manual relationship for now. Its unfortunate, and in the future we can provide like a tenant_setter option that will take a record and figure out what tenant it should get its multitenant related things from

Did you find this page helpful?