I’m wondering if there is another shorter way to write the below code:
<script lang="ts">
const playerList = query(playerListQuery, { input: { pagination, where } });
$: {
playerList.variables = {
input: {
pagination,
order: { field: PlayerOrderField.CreatedAtDesc },
where: {
// some others...
},
},
};
if (searchValue) {
playerList.variables = {
...playerList.variables,
input: {
...playerList.variables.input,
where: {
...playerList.variables.input.where,
or: [
{ nameContains: searchValue },
{
teamHas: [
{
or: [
{ nameContains: searchValue },
{ addressContains: searchValue },
],
},
],
},
],
},
},
};
}
}
</script>
As you can see I’m only interested to extend the where
field (if (searchValue)
) but using Svelte I need to recreate/assign all the playerList.variables
.
Is there a shorter way?