You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: join field defaultLimit and defaultSort (#8908)
### What?
Allow specifying the defaultSort and defaultLimit to use for populating
a join field
### Why?
It is much easier to set defaults rather than be forced to always call
the join query using the query pattern ("?joins[categories][limit]=0").
### How?
See docs and type changes
The Join Field is used to make Relationship and Upload fields available in the opposite direction. With a Join you can edit and view collections
10
-
having reference to a specific collection document. The field itself acts as a virtual field, in that no new data is stored on the collection with a Join
9
+
The Join Field is used to make Relationship and Upload fields available in the opposite direction. With a Join you can
10
+
edit and view collections
11
+
having reference to a specific collection document. The field itself acts as a virtual field, in that no new data is
12
+
stored on the collection with a Join
11
13
field. Instead, the Admin UI surfaces the related documents for a better editing experience and is surfaced by Payload's
12
14
APIs.
13
15
@@ -19,10 +21,10 @@ The Join field is useful in scenarios including:
19
21
- Displaying where a document or upload is used in other documents
For the Join field to work, you must have an existing [relationship](./relationship) or [upload](./upload) field in the
@@ -111,9 +113,11 @@ related docs from a new pseudo-junction collection called `categories_posts`. No
111
113
third junction collection, and can be surfaced on both Posts and Categories. But, importantly, you could add
112
114
additional "context" fields to this shared junction collection.
113
115
114
-
For example, on this `categories_posts` collection, in addition to having the `category` and `post` fields, we could add custom "context" fields like `featured` or `spotlight`,
116
+
For example, on this `categories_posts` collection, in addition to having the `category` and `post` fields, we could add
117
+
custom "context" fields like `featured` or `spotlight`,
115
118
which would allow you to store additional information directly on relationships.
116
-
The `join` field gives you complete control over any type of relational architecture in Payload, all wrapped up in a powerful Admin UI.
119
+
The `join` field gives you complete control over any type of relational architecture in Payload, all wrapped up in a
120
+
powerful Admin UI.
117
121
118
122
## Config Options
119
123
@@ -126,11 +130,11 @@ The `join` field gives you complete control over any type of relational architec
126
130
|**`label`**| Text used as a field label in the Admin Panel or an object with keys for each language. |
127
131
|**`hooks`**| Provide Field Hooks to control logic for this field. [More details](../hooks/fields). |
128
132
|**`access`**| Provide Field Access Control to denote what users can see and do with this field's data. [More details](../access-control/fields). |
129
-
|**`localized`**| Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config.|
130
-
|**`required`**| Require this field to have a value. |
133
+
|**`defaultLimit`**| The number of documents to return. Set to 0 to return all related documents. |
134
+
|**`defaultSort`**| The field name used to specify the order the joined documents are returned.|
131
135
|**`admin`**| Admin-specific configuration. |
132
-
|**`custom`**| Extension point for adding custom data (e.g. for plugins)|
133
-
|**`typescriptSchema`**| Override field type generation with providing a JSON schema|
136
+
|**`custom`**| Extension point for adding custom data (e.g. for plugins).|
137
+
|**`typescriptSchema`**| Override field type generation with providing a JSON schema.|
134
138
135
139
_\* An asterisk denotes that a property is required._
136
140
@@ -150,12 +154,12 @@ object with:
150
154
{
151
155
"id": "66e3431a3f23e684075aaeb9",
152
156
// other fields...
153
-
"category": "66e3431a3f23e684075aae9c",
154
-
},
157
+
"category": "66e3431a3f23e684075aae9c"
158
+
}
155
159
// { ... }
156
160
],
157
161
"hasNextPage": false
158
-
},
162
+
}
159
163
// other fields...
160
164
}
161
165
```
@@ -213,7 +217,8 @@ You can specify as many `joins` parameters as needed for the same or different j
213
217
214
218
### GraphQL
215
219
216
-
The GraphQL API supports the same query options as the local and REST APIs. You can specify the query options for each join field in your query.
220
+
The GraphQL API supports the same query options as the local and REST APIs. You can specify the query options for each
0 commit comments