feat: generate types for joins (#9054)
### What? Generates types for `joins` property. Example from our `joins` test, keys are type-safe: <img width="708" alt="image" src="https://github.com/user-attachments/assets/f1fbbb9d-7c39-49a2-8aa2-a4793ae4ad7e"> Output in `payload-types.ts`: ```ts collectionsJoins: { categories: { relatedPosts: 'posts'; hasManyPosts: 'posts'; hasManyPostsLocalized: 'posts'; 'group.relatedPosts': 'posts'; 'group.camelCasePosts': 'posts'; filtered: 'posts'; singulars: 'singular'; }; }; ``` Additionally, we include type information about on which collection the join is, it will help when we have types generation for `where` and `sort`. ### Why? It provides a better DX as you don't need to memoize your keys. ### How? Modifies `configToJSONSchema` to generate the json schema for `collectionsJoins`, uses that type within `JoinQuery`
This commit is contained in:
@@ -21,6 +21,7 @@ export interface Config {
|
||||
'payload-preferences': PayloadPreference;
|
||||
'payload-migrations': PayloadMigration;
|
||||
};
|
||||
collectionsJoins: {};
|
||||
collectionsSelect: {
|
||||
posts: PostsSelect<false> | PostsSelect<true>;
|
||||
'localized-posts': LocalizedPostsSelect<false> | LocalizedPostsSelect<true>;
|
||||
|
||||
Reference in New Issue
Block a user