Skip to content

No refetchObservableQueries - #293

Open
PowerKiKi wants to merge 2 commits into
masterfrom
issue-12584-no-automatic-refetch
Open

No refetchObservableQueries#293
PowerKiKi wants to merge 2 commits into
masterfrom
issue-12584-no-automatic-refetch

Conversation

@PowerKiKi

Copy link
Copy Markdown
Member

The most common use case for modelService.delete() is from a page detail, and after deletion the user is redirected to the page listing. So there is no need to refetchObservableQueries() unconditionally.

Other use cases

For other use cases we can reload specific queries like those examples.

Dialog

From a dialog on top of the listing page:

this.itemService
    .delete([id], {
        // Wait till we refresh the list under the dialog before closing the dialog, to avoid re-clicking on the just deleted item
        refetchQueries: [itemsQuery],
        awaitRefetchQueries: true,
    })
    .subscribe({
        next: () => {
            this.alertService.info(`Supprimé`);
            this.dialogRef.close();
        }
    });

Inline deletion in listing

From a listing page where deletion is directly accessible on the row:

this.itemService.delete([id], {
    refetchQueries: [itemsQuery],
}).subscribe({
    next: () => {
        this.alertService.info(`Supprimé`);
    },
    error: () => this.deleting.delete(id),
});

Bulk deleting

Bulk deleting via NaturalAbstractList.bulkDelete() still automatically refetch the listing of items, but no other queries anymore.

…)` #12584

The most common use case for `modelService.delete()` is from a page
detail, and after deletion the user is redirected to the page listing.
So there is no need to `refetchObservableQueries()` unconditionally.

# Other use cases

For other use cases we can reload specific queries like those
examples.

## Dialog

From a dialog on top of the listing page:

```ts
this.itemService
    .delete([id], {
        // Wait till we refresh the list under the dialog before closing the dialog, to avoid re-clicking on the just deleted item
        refetchQueries: [itemsQuery],
        awaitRefetchQueries: true,
    })
    .subscribe({
        next: () => {
            this.alertService.info(`Supprimé`);
            this.dialogRef.close();
        }
    });
```

## Inline deletion in listing

From a listing page where deletion is directly accessible on the row:

```ts
this.itemService.delete([id], {
    refetchQueries: [itemsQuery],
}).subscribe({
    next: () => {
        this.alertService.info(`Supprimé`);
    },
    error: () => this.deleting.delete(id),
});
```

## Bulk deleting

Bulk deleting via `NaturalAbstractList.bulkDelete()` still automatically
refetch the listing of items, but no other queries anymore.
…)` #12584

The most common use case for `modelService.create()` is from a page
detail for creation, and after the creation the user is redirected
to the page detail for edition. So there is no need to
`refetchObservableQueries()` unconditionally.

# Other use cases

For other use cases we can reload specific queries like those
examples.

## Dialog

From a dialog on top of the listing page:

```ts
this.itemService
    .create({...}, {
        // Refresh the list under the dialog
        refetchQueries: [itemsQuery]
    })
    .subscribe(newItem => {
        this.alertService.info('Créé');
        this.dialogRef.close(newItem);
});
```

## Inline creation in listing

From a listing page where row creation is inline, there is nothing to do,
because the row already exists before we even mutate the server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant