chore: Use string IDs instead of integer ones

This commit is contained in:
Faruk AYDIN
2022-01-29 13:59:52 +03:00
committed by Ömer Faruk Aydın
parent 86d5cceec7
commit c6e2b94128
27 changed files with 157 additions and 135 deletions

View File

@@ -14,13 +14,10 @@ import type { Step } from 'types/step';
type EditorProps = {
flow: Flow;
}
};
function updateHandlerFactory(flowId: number, previousStepId: number) {
return function createStepUpdateHandler(
cache: any,
mutationResult: any,
) {
function updateHandlerFactory(flowId: string, previousStepId: string) {
return function createStepUpdateHandler(cache: any, mutationResult: any) {
const { data } = mutationResult;
const { createStep: createdStep } = data;
const { getFlow: flow } = cache.readQuery({
@@ -40,7 +37,7 @@ function updateHandlerFactory(flowId: number, previousStepId: number) {
variables: { id: flowId },
data: { getFlow: { ...flow, steps } },
});
}
};
}
export default function Editor(props: EditorProps): React.ReactElement {
@@ -49,41 +46,47 @@ export default function Editor(props: EditorProps): React.ReactElement {
const [currentStep, setCurrentStep] = React.useState<number | null>(0);
const { flow } = props;
const onStepChange = React.useCallback((step: any) => {
const mutationInput: Record<string, unknown> = {
id: step.id,
key: step.key,
parameters: JSON.stringify(step.parameters, null, 2),
connection: {
id: step.connection?.id
},
flow: {
id: flow.id,
},
};
const onStepChange = React.useCallback(
(step: any) => {
const mutationInput: Record<string, unknown> = {
id: step.id,
key: step.key,
parameters: JSON.stringify(step.parameters, null, 2),
connection: {
id: step.connection?.id,
},
flow: {
id: flow.id,
},
};
if (step.appKey) {
mutationInput.appKey = step.appKey;
}
if (step.appKey) {
mutationInput.appKey = step.appKey;
}
updateStep({ variables: { input: mutationInput } });
}, [updateStep, flow.id]);
updateStep({ variables: { input: mutationInput } });
},
[updateStep, flow.id]
);
const addStep = React.useCallback((previousStepId) => {
const mutationInput = {
previousStep: {
id: previousStepId,
},
flow: {
id: flow.id,
},
};
const addStep = React.useCallback(
(previousStepId) => {
const mutationInput = {
previousStep: {
id: previousStepId,
},
flow: {
id: flow.id,
},
};
createStep({
variables: { input: mutationInput },
update: updateHandlerFactory(flow.id, previousStepId),
});
}, [createStep, flow.id]);
createStep({
variables: { input: mutationInput },
update: updateHandlerFactory(flow.id, previousStepId),
});
},
[createStep, flow.id]
);
return (
<Box
@@ -113,5 +116,5 @@ export default function Editor(props: EditorProps): React.ReactElement {
</React.Fragment>
))}
</Box>
)
};
);
}

View File

@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';
export const CREATE_AUTH_DATA = gql`
mutation createAuthData($id: Int!) {
mutation createAuthData($id: String!) {
createAuthData(id: $id) {
url
}

View File

@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';
export const DELETE_CONNECTION = gql`
mutation DeleteConnection($id: Int!) {
mutation DeleteConnection($id: String!) {
deleteConnection(id: $id)
}
`;

View File

@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';
export const RESET_CONNECTION = gql`
mutation ResetConnection($id: Int!) {
mutation ResetConnection($id: String!) {
resetConnection(id: $id) {
id
}

View File

@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';
export const UPDATE_CONNECTION = gql`
mutation UpdateConnection($id: Int!, $data: JSONObject!) {
mutation UpdateConnection($id: String!, $data: JSONObject!) {
updateConnection(id: $id, data: $data) {
id
key

View File

@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';
export const VERIFY_CONNECTION = gql`
mutation VerifyConnection($id: Int!) {
mutation VerifyConnection($id: String!) {
verifyConnection(id: $id) {
id
verified

View File

@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';
export const GET_FLOW = gql`
query GetFlow($id: Int!) {
query GetFlow($id: String!) {
getFlow(id: $id) {
id
name

View File

@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';
export const TEST_CONNECTION = gql`
query TestConnection($id: Int!) {
query TestConnection($id: String!) {
testConnection(id: $id) {
id
verified

View File

@@ -1,7 +1,7 @@
import type { Step } from './step';
export type Flow = {
id: number;
id: string;
name: string;
steps: Step[];
active: boolean;

View File

@@ -9,9 +9,9 @@ export type Step = {
name: string;
appKey: string;
type: StepType;
previousStepId: number | null;
previousStepId: string | null;
parameters: Record<string, unknown>;
connection: {
id: number;
id: string;
};
};