Add entity type for individual Term objects#62504
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
tyxla
left a comment
There was a problem hiding this comment.
This looks pretty good, thanks @fabiankaegy 🙌
The primary thing that we should check is whether we're correctly providing the context of each field. Or perhaps you're intentionally skipping them?
Other than that, I think this is good to go!
| /** | ||
| * Meta fields for the term. | ||
| */ | ||
| meta: { [ key: string ]: unknown }; |
There was a problem hiding this comment.
Isn't meta essentially an associative array of meta fields? And because of the database schema, they'll always end up strings?
Also it supports view and edit contexts, right?
| meta: { [ key: string ]: unknown }; | |
| meta: ContextualField< | |
| Record< string, string >, | |
| 'view' | 'edit', | |
| C | |
| >; |
| /** | ||
| * The title for the term. | ||
| */ | ||
| name: string; |
There was a problem hiding this comment.
According to the REST API docs, this can be available in multiple contexts:
| name: string; | |
| name: ContextualField< string, 'view' | 'embed' | 'edit', C >; |
| /** | ||
| * An alphanumeric identifier for the term. | ||
| */ | ||
| slug: string; |
There was a problem hiding this comment.
Same as above:
| slug: string; | |
| slug: ContextualField< string, 'view' | 'embed' | 'edit', C >; |
| */ | ||
| name: string; | ||
| /** | ||
| * An alphanumeric identifier for the term. |
There was a problem hiding this comment.
I've always found the "alphanumeric" description ambiguous, considering that terms can also contain dashes.
| /** | ||
| * The number of objects with the term. | ||
| */ | ||
| count: number; |
There was a problem hiding this comment.
I'd suggest auditing all fields for context. count seems to be available for view and edit and not for embed.
What?
Adds a new
Termtype to the available entity types exported from thecore-datapackage.Why?
' getEntityRecord' is commonly used to deal with individual terms outside of any taxonomy. Currently, we don't expose any types for it.
How?
Adding the type to the correct folder and exporting it.