feat: Convert all mutation files to js
This commit is contained in:
33
packages/backend/src/graphql/mutations/update-connection.js
Normal file
33
packages/backend/src/graphql/mutations/update-connection.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import AppAuthClient from '../../models/app-auth-client';
|
||||
|
||||
const updateConnection = async (_parent, params, context) => {
|
||||
context.currentUser.can('create', 'Connection');
|
||||
|
||||
let connection = await context.currentUser
|
||||
.$relatedQuery('connections')
|
||||
.findOne({
|
||||
id: params.input.id,
|
||||
})
|
||||
.throwIfNotFound();
|
||||
|
||||
let formattedData = params.input.formattedData;
|
||||
|
||||
if (params.input.appAuthClientId) {
|
||||
const appAuthClient = await AppAuthClient.query()
|
||||
.findById(params.input.appAuthClientId)
|
||||
.throwIfNotFound();
|
||||
|
||||
formattedData = appAuthClient.formattedAuthDefaults;
|
||||
}
|
||||
|
||||
connection = await connection.$query().patchAndFetch({
|
||||
formattedData: {
|
||||
...connection.formattedData,
|
||||
...formattedData,
|
||||
},
|
||||
});
|
||||
|
||||
return connection;
|
||||
};
|
||||
|
||||
export default updateConnection;
|
Reference in New Issue
Block a user