Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Core Data: Check for presence of entity config before testing plural …
…form.

When auto-generating method names for various entities in the data system we
want to use manually-listed plural forms if they exist.

Previously, however, we've been assuming that when we search for an entity's
config that it exists. While this probably hasn't been a real source of bugs
it does present an opportunity for an invalid-type runtime exception.

In this patch we're verifying that the config exists before we access the
`plural` property, eliminating the opportunity for the rutnime crash.
  • Loading branch information
dmsnell authored and adamziel committed Mar 16, 2022
commit a764b9bd8fef033cddfa9b82b264ddc640f6789f
2 changes: 1 addition & 1 deletion packages/core-data/src/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export const getMethodName = (
const nameSuffix =
upperFirst( camelCase( name ) ) + ( usePlural ? 's' : '' );
const suffix =
usePlural && entityConfig.plural
usePlural && entityConfig?.plural
? upperFirst( camelCase( entityConfig.plural ) )
: nameSuffix;
return `${ prefix }${ kindPrefix }${ suffix }`;
Expand Down