chore: remove redundant create connection mutation
This commit is contained in:
@@ -2,12 +2,10 @@
|
||||
import verifyConnection from './mutations/verify-connection.js';
|
||||
import updateCurrentUser from './mutations/update-current-user.js';
|
||||
import generateAuthUrl from './mutations/generate-auth-url.js';
|
||||
import createConnection from './mutations/create-connection.js';
|
||||
import resetConnection from './mutations/reset-connection.js';
|
||||
import updateConnection from './mutations/update-connection.js';
|
||||
|
||||
const mutationResolvers = {
|
||||
createConnection,
|
||||
generateAuthUrl,
|
||||
resetConnection,
|
||||
updateConnection,
|
||||
|
@@ -1,48 +0,0 @@
|
||||
import App from '../../models/app.js';
|
||||
import AppConfig from '../../models/app-config.js';
|
||||
|
||||
const createConnection = async (_parent, params, context) => {
|
||||
context.currentUser.can('create', 'Connection');
|
||||
|
||||
const { key, appAuthClientId } = params.input;
|
||||
|
||||
const app = await App.findOneByKey(key);
|
||||
|
||||
const appConfig = await AppConfig.query().findOne({ key });
|
||||
|
||||
let formattedData = params.input.formattedData;
|
||||
if (appConfig) {
|
||||
if (appConfig.disabled)
|
||||
throw new Error(
|
||||
'This application has been disabled for new connections!'
|
||||
);
|
||||
|
||||
if (!appConfig.allowCustomConnection && formattedData)
|
||||
throw new Error(`Custom connections cannot be created for ${app.name}!`);
|
||||
|
||||
if (appConfig.shared && !formattedData) {
|
||||
const authClient = await appConfig
|
||||
.$relatedQuery('appAuthClients')
|
||||
.findById(appAuthClientId)
|
||||
.where({
|
||||
active: true,
|
||||
})
|
||||
.throwIfNotFound();
|
||||
|
||||
formattedData = authClient.formattedAuthDefaults;
|
||||
}
|
||||
}
|
||||
|
||||
const createdConnection = await context.currentUser
|
||||
.$relatedQuery('connections')
|
||||
.insert({
|
||||
key,
|
||||
appAuthClientId,
|
||||
formattedData,
|
||||
verified: false,
|
||||
});
|
||||
|
||||
return createdConnection;
|
||||
};
|
||||
|
||||
export default createConnection;
|
@@ -2,7 +2,6 @@ type Query {
|
||||
placeholderQuery(name: String): Boolean
|
||||
}
|
||||
type Mutation {
|
||||
createConnection(input: CreateConnectionInput): Connection
|
||||
generateAuthUrl(input: GenerateAuthUrlInput): AuthLink
|
||||
resetConnection(input: ResetConnectionInput): Connection
|
||||
updateConnection(input: UpdateConnectionInput): Connection
|
||||
@@ -202,12 +201,6 @@ type SamlAuthProvidersRoleMapping {
|
||||
remoteRoleName: String
|
||||
}
|
||||
|
||||
input CreateConnectionInput {
|
||||
key: String!
|
||||
appAuthClientId: String
|
||||
formattedData: JSONObject
|
||||
}
|
||||
|
||||
input GenerateAuthUrlInput {
|
||||
id: String!
|
||||
}
|
||||
|
@@ -1,13 +0,0 @@
|
||||
import { gql } from '@apollo/client';
|
||||
export const CREATE_CONNECTION = gql`
|
||||
mutation CreateConnection($input: CreateConnectionInput) {
|
||||
createConnection(input: $input) {
|
||||
id
|
||||
key
|
||||
verified
|
||||
formattedData {
|
||||
screenName
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
@@ -1,10 +1,9 @@
|
||||
import { CREATE_CONNECTION } from './create-connection';
|
||||
import { UPDATE_CONNECTION } from './update-connection';
|
||||
import { VERIFY_CONNECTION } from './verify-connection';
|
||||
import { RESET_CONNECTION } from './reset-connection';
|
||||
import { GENERATE_AUTH_URL } from './generate-auth-url';
|
||||
|
||||
const mutations = {
|
||||
createConnection: CREATE_CONNECTION,
|
||||
updateConnection: UPDATE_CONNECTION,
|
||||
verifyConnection: VERIFY_CONNECTION,
|
||||
resetConnection: RESET_CONNECTION,
|
||||
|
Reference in New Issue
Block a user