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
Describe the bug
When trying to create hooks the CreateOrUpdateHookParams<G> type is frustrating to work with.
It has an entities property, but that property is not actually there at runtime, the correct one to be using is args.items.
args.items is of type Partial<G>[], which is...kind of correct, but nested entities are not typed correctly as GQL inputs, for example if this entity has a many to one relationship with another, and you want to set the foreign key, you'd do this: params.args.items?.forEach((entity) => entity.relationshipProperty = { id: '5' }, which is perfectly valid, but the types tell you that you need to fill out all properties on this entity, which is not true.
params.context is not typed well at all, and it's difficult to pull values out of the user context to reference in your hook.
To Reproduce
Steps to reproduce the behaviour:
Build a hook that sets the current user as createdBy on every entity of that type which is created.
Expected behavior
Expected types to correctly define the shape of the context, or at least provide a generic param for it. Also expected types to be aware of foreign key reference assignments.
Actual behavior
What actually happened.
Point 2:
Type '{ id: string; }' is missing the following properties from type 'OtherEntity': [all required fields](2740);
Point 3:
Property 'user' does not exist on type 'object'.ts(2339)
The text was updated successfully, but these errors were encountered:
Describe the bug
When trying to create hooks the
CreateOrUpdateHookParams<G>
type is frustrating to work with.entities
property, but that property is not actually there at runtime, the correct one to be using isargs.items
.args.items
is of typePartial<G>[]
, which is...kind of correct, but nested entities are not typed correctly as GQL inputs, for example if this entity has a many to one relationship with another, and you want to set the foreign key, you'd do this:params.args.items?.forEach((entity) => entity.relationshipProperty = { id: '5' }
, which is perfectly valid, but the types tell you that you need to fill out all properties on this entity, which is not true.params.context
is not typed well at all, and it's difficult to pull values out of the user context to reference in your hook.To Reproduce
Steps to reproduce the behaviour:
Build a hook that sets the current user as
createdBy
on every entity of that type which is created.Expected behavior
Expected types to correctly define the shape of the context, or at least provide a generic param for it. Also expected types to be aware of foreign key reference assignments.
Actual behavior
What actually happened.
Point 2:
Point 3:
The text was updated successfully, but these errors were encountered: