refactor: Use generateAuthUrl method instead of createAuthData

This commit is contained in:
Faruk AYDIN
2022-11-10 18:50:36 +01:00
parent 10e2794ff9
commit 81c41ef5ee
21 changed files with 42 additions and 50 deletions

View File

@@ -1,5 +1,5 @@
import createConnection from './mutations/create-connection';
import createAuthData from './mutations/create-auth-data';
import generateAuthUrl from './mutations/generate-auth-url';
import updateConnection from './mutations/update-connection';
import resetConnection from './mutations/reset-connection';
import verifyConnection from './mutations/verify-connection';
@@ -17,7 +17,7 @@ import login from './mutations/login';
const mutationResolvers = {
createConnection,
createAuthData,
generateAuthUrl,
updateConnection,
resetConnection,
verifyConnection,

View File

@@ -2,7 +2,7 @@ import Context from '../../types/express/context';
import axios from 'axios';
import globalVariable from '../../helpers/global-variable';
import App from '../../models/app';
import CreateAuthDataError from '../../errors/create-auth-data';
import GenerateAuthUrlError from '../../errors/generate-auth-url';
type Params = {
input: {
@@ -10,7 +10,7 @@ type Params = {
};
};
const createAuthData = async (
const generateAuthUrl = async (
_parent: unknown,
params: Params,
context: Context
@@ -32,13 +32,13 @@ const createAuthData = async (
const $ = await globalVariable({ connection, app });
try {
await authInstance.createAuthData($);
await authInstance.generateAuthUrl($);
await axios.get(connection.formattedData.url as string);
} catch (error) {
throw new CreateAuthDataError(error);
throw new GenerateAuthUrlError(error);
}
return connection.formattedData;
};
export default createAuthData;
export default generateAuthUrl;

View File

@@ -30,7 +30,7 @@ type Query {
type Mutation {
createConnection(input: CreateConnectionInput): Connection
createAuthData(input: CreateAuthDataInput): AuthLink
generateAuthUrl(input: GenerateAuthUrlInput): AuthLink
updateConnection(input: UpdateConnectionInput): Connection
resetConnection(input: ResetConnectionInput): Connection
verifyConnection(input: VerifyConnectionInput): Connection
@@ -225,7 +225,7 @@ input CreateConnectionInput {
formattedData: JSONObject!
}
input CreateAuthDataInput {
input GenerateAuthUrlInput {
id: String!
}