Closed Bradleykingz closed 1 year ago
Changing hidden: false
in resourceTenant
fixes the issue.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createResourceTenantField = void 0;
/** @returns Tenant field for generic resources. */
var createResourceTenantField = function (_a) {
var tenantCollection = _a.options.tenantCollection;
return ({
type: "relationship",
name: "tenant",
relationTo: tenantCollection,
hidden: false, // changed this
hooks: {
beforeChange: [
function (_a) {
var _b;
var req = _a.req;
// Assign tenant to the document when it's created (or updated).
var _c = req, tenant = _c.tenant, user = _c.user;
return (tenant === null || tenant === void 0 ? void 0 : tenant.id) || ((_b = user === null || user === void 0 ? void 0 : user.tenant) === null || _b === void 0 ? void 0 : _b.id);
},
],
},
});
};
exports.createResourceTenantField = createResourceTenantField;
The compiled code looks different from what's in the repo. Maybe https://github.com/joas8211/payload-tenancy/commit/fc7c4f7b451dfc391efb97a7a8be4be3c14a7874 is missing from npm?
Yup. Just confirmed it. npm is behind.
@joas8211 Do you mind creating a new release? :slightly_smiling_face:
I fixed this by updating Payload, confusingly :sweat_smile:
When querying resource collections, the
tenant
field is not returned, making it impossible for the frontend to filter documents according to the tenant.For example, here is the "pages" resource.
Even querying via GraphQL leads to the same result - tenant is always null.
And, since the
tenant
field doesn't exist, the frontend can't filter bytenant id
, and users can see each other's documents.Adding
hidden: false
to theCollectionConfig
seems to help, but only when querying for a single page:But when querying all the pages, it remains null:
However, it works just fine for the user collection:
Any clues what the issue might be?