joas8211 / payload-tenancy

Multi-tenancy plugin for Payload CMS
MIT License
150 stars 11 forks source link

Fix user tenant resolution and globals with required fields #26

Closed balinthaller closed 1 year ago

balinthaller commented 1 year ago

Hey,

This PR fixes two things I've run into while using the plugin (many thanks for it by the way, has been super useful!).

  1. Occasionally the 'tenant' reference isn't resolved on the user (for instance when calling the local API from a GraphQL resolver), so we can't see its id field. This falls back to just the tenant string in that case.
  2. I wasn't able to update globals with required fields, since the initGlobal function tried to create an empty document first, which failed validation. Now we create the document under the hood with data populated right away.
balinthaller commented 1 year ago

Sorry for leaving this, haven't worked on this project a lot the last couple weeks. Thanks a lot for seeing it through and merging!