refactor: Use input params for all mutations
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
212523aec6
commit
bb36748764
@@ -2,8 +2,10 @@ import Context from '../../types/express/context';
|
||||
import { IJSONObject } from '@automatisch/types';
|
||||
|
||||
type Params = {
|
||||
id: string;
|
||||
formattedData: IJSONObject;
|
||||
input: {
|
||||
id: string;
|
||||
formattedData: IJSONObject;
|
||||
};
|
||||
};
|
||||
|
||||
const updateConnection = async (
|
||||
@@ -14,14 +16,14 @@ const updateConnection = async (
|
||||
let connection = await context.currentUser
|
||||
.$relatedQuery('connections')
|
||||
.findOne({
|
||||
id: params.id,
|
||||
id: params.input.id,
|
||||
})
|
||||
.throwIfNotFound();
|
||||
|
||||
connection = await connection.$query().patchAndFetch({
|
||||
formattedData: {
|
||||
...connection.formattedData,
|
||||
...params.formattedData,
|
||||
...params.input.formattedData,
|
||||
},
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user