Skip to content

UpdateCollection doesn't support partial updates according to type #419

@vera

Description

@vera

The Dataverse API docs state:

Prepare a JSON file containing the fields for the properties you want to update. You do not need to include all the properties, only the ones you want to update.

https://guides.dataverse.org/en/latest/api/native-api.html#update-a-dataverse-collection

However, the UpdateCollection use case uses the CollectionDTO type for the updatedCollection param (see https://github.com/IQSS/dataverse-client-javascript/blob/develop/src/collections/domain/useCases/UpdateCollection.ts), which means that a number of fields is required, and if I try to execute a partial update, I receive a type warning:

TS2345: Argument of type '{ name: string; description: string; contacts: string[]; }' is not assignable to parameter of type 'CollectionDTO'.
  Type '{ name: string; description: string; contacts: string[]; }' is missing the following properties from type 'CollectionDTO': alias, type, inheritMetadataBlocksFromParent, inheritFacetsFromParent
    80 |   const { mutate: save, isLoading: isSaving } = useMutation({
    81 |     mutationFn: async (data: EditCollectionFormData) => {
  > 82 |       await updateCollection.execute(collectionId!, {
       |                                                     ^
  > 83 |         name: data.title,
       | ^^^^^^^^^^^^^^^^^^^^^^^^^
  > 84 |         description: data.description,
       | ^^^^^^^^^^^^^^^^^^^^^^^^^
  > 85 |         contacts: data.contacts,
       | ^^^^^^^^^^^^^^^^^^^^^^^^^
  > 86 |       });
       | ^^^^^^^^
    87 |     },

I can ignore the type warning and successfully execute the partial update anyways, since the Dataverse API supports it, so it would be nice to update the type so that I don't receive a warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions