neogma
neogma copied to clipboard
Where parameters do not have relationship typings
https://github.com/themetalfleece/neogma/blob/da28eccb3221476d5d7693be65f84297d8ea0532/src/Queries/Where/Where.ts#L109-L116
The key of WhereParamsI
is a string
type. This can cause errors that are difficult to debug. For example:
user.findRelationships({
alias: 'Group',
where: { target: { grpName: 'Administrators' } },
});
If the model of user groups has a property called groupName
then this will fail only at runtime when findRelationships
returns zero results.
It would be better if the key of WhereParamsI
were typed to be the keys of the related node properties.
That's true, but it's a bit difficult to type properly for nested relationships with where
. I'll have a fresh look though.
Until then, you can use the satisfies
keyword to add some inline type safety, like:
where: {
name: 'Jason'
} satisfies Partial<UserProperties>