refactor: introduce input in gql mutations
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
f5f7a998ca
commit
030d886cf7
@@ -217,11 +217,25 @@ input DeleteFlowInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
input CreateStepInput {
|
input CreateStepInput {
|
||||||
input: StepInput!
|
id: String
|
||||||
|
previousStepId: String
|
||||||
|
key: String
|
||||||
|
appKey: String
|
||||||
|
connection: StepConnectionInput
|
||||||
|
flow: StepFlowInput
|
||||||
|
parameters: JSONObject
|
||||||
|
previousStep: PreviousStepInput
|
||||||
}
|
}
|
||||||
|
|
||||||
input UpdateStepInput {
|
input UpdateStepInput {
|
||||||
input: StepInput!
|
id: String
|
||||||
|
previousStepId: String
|
||||||
|
key: String
|
||||||
|
appKey: String
|
||||||
|
connection: StepConnectionInput
|
||||||
|
flow: StepFlowInput
|
||||||
|
parameters: JSONObject
|
||||||
|
previousStep: PreviousStepInput
|
||||||
}
|
}
|
||||||
|
|
||||||
input DeleteStepInput {
|
input DeleteStepInput {
|
||||||
|
@@ -33,7 +33,7 @@ export default function AddNewAppConnection(props: AddNewAppConnectionProps): Re
|
|||||||
const matchSmallScreens = useMediaQuery(theme.breakpoints.down('sm'));
|
const matchSmallScreens = useMediaQuery(theme.breakpoints.down('sm'));
|
||||||
const formatMessage = useFormatMessage();
|
const formatMessage = useFormatMessage();
|
||||||
const [appName, setAppName] = React.useState<string | null>(null);
|
const [appName, setAppName] = React.useState<string | null>(null);
|
||||||
const { data } = useQuery(GET_APPS, { variables: {name: appName } });
|
const { data } = useQuery(GET_APPS, { variables: { name: appName } });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={true} onClose={onClose} maxWidth="sm" fullWidth>
|
<Dialog open={true} onClose={onClose} maxWidth="sm" fullWidth>
|
||||||
|
@@ -55,7 +55,7 @@ function AppConnectionRow(props: AppConnectionRowProps): React.ReactElement {
|
|||||||
const onContextMenuAction = React.useCallback(async (event, action: { [key: string]: string }) => {
|
const onContextMenuAction = React.useCallback(async (event, action: { [key: string]: string }) => {
|
||||||
if (action.type === 'delete') {
|
if (action.type === 'delete') {
|
||||||
await deleteConnection({
|
await deleteConnection({
|
||||||
variables: { id },
|
variables: { input: { id } },
|
||||||
update: (cache) => {
|
update: (cache) => {
|
||||||
const connectionCacheId = cache.identify({
|
const connectionCacheId = cache.identify({
|
||||||
__typename: 'Connection',
|
__typename: 'Connection',
|
||||||
@@ -71,7 +71,7 @@ function AppConnectionRow(props: AppConnectionRowProps): React.ReactElement {
|
|||||||
enqueueSnackbar(formatMessage('connection.deletedMessage'), { variant: 'success' });
|
enqueueSnackbar(formatMessage('connection.deletedMessage'), { variant: 'success' });
|
||||||
} else if (action.type === 'test') {
|
} else if (action.type === 'test') {
|
||||||
setVerificationVisible(true);
|
setVerificationVisible(true);
|
||||||
testConnection({ variables: { id } });
|
testConnection({ variables: { input: { id } } });
|
||||||
}
|
}
|
||||||
}, [deleteConnection, id, testConnection, formatMessage, enqueueSnackbar]);
|
}, [deleteConnection, id, testConnection, formatMessage, enqueueSnackbar]);
|
||||||
|
|
||||||
|
@@ -50,12 +50,21 @@ function ChooseAccountSubstep(props: ChooseAccountSubstepProps): React.ReactElem
|
|||||||
loading: testResultLoading,
|
loading: testResultLoading,
|
||||||
refetch: retestConnection
|
refetch: retestConnection
|
||||||
}
|
}
|
||||||
] = useLazyQuery (TEST_CONNECTION, { variables: { id: connection?.id, }});
|
] = useLazyQuery(
|
||||||
|
TEST_CONNECTION,
|
||||||
|
{
|
||||||
|
variables: {
|
||||||
|
input: { id: connection?.id, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (connection?.id) {
|
if (connection?.id) {
|
||||||
testConnection({
|
testConnection({
|
||||||
variables: { id: connection?.id },
|
variables: {
|
||||||
|
input: { id: connection.id, }
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// intentionally no dependencies for initial test
|
// intentionally no dependencies for initial test
|
||||||
@@ -88,7 +97,9 @@ function ChooseAccountSubstep(props: ChooseAccountSubstepProps): React.ReactElem
|
|||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (step.connection?.id) {
|
if (step.connection?.id) {
|
||||||
retestConnection({
|
retestConnection({
|
||||||
id: step.connection.id,
|
input: {
|
||||||
|
id: step.connection.id,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [step.connection?.id, retestConnection])
|
}, [step.connection?.id, retestConnection])
|
||||||
|
@@ -27,8 +27,10 @@ export default function EditorLayout(): React.ReactElement {
|
|||||||
const onFlowNameUpdate = React.useCallback(async (name: string) => {
|
const onFlowNameUpdate = React.useCallback(async (name: string) => {
|
||||||
await updateFlow({
|
await updateFlow({
|
||||||
variables: {
|
variables: {
|
||||||
id: flowId,
|
input: {
|
||||||
name,
|
id: flowId,
|
||||||
|
name,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
optimisticResponse: {
|
optimisticResponse: {
|
||||||
__typename: 'Mutation',
|
__typename: 'Mutation',
|
||||||
|
@@ -51,8 +51,6 @@ export default function FlowStep(props: FlowStepProps): React.ReactElement | nul
|
|||||||
{
|
{
|
||||||
data: stepWithTestExecutionsData,
|
data: stepWithTestExecutionsData,
|
||||||
called: stepWithTestExecutionsCalled,
|
called: stepWithTestExecutionsCalled,
|
||||||
loading: stepWithTestExecutionsLoading,
|
|
||||||
error: stepWithTestExecutionsError
|
|
||||||
},
|
},
|
||||||
] = useLazyQuery(GET_STEP_WITH_TEST_EXECUTIONS, {
|
] = useLazyQuery(GET_STEP_WITH_TEST_EXECUTIONS, {
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
@@ -62,7 +60,9 @@ export default function FlowStep(props: FlowStepProps): React.ReactElement | nul
|
|||||||
if (!stepWithTestExecutionsCalled && !collapsed && !isTrigger) {
|
if (!stepWithTestExecutionsCalled && !collapsed && !isTrigger) {
|
||||||
getStepWithTestExecutions({
|
getStepWithTestExecutions({
|
||||||
variables: {
|
variables: {
|
||||||
stepId: step.id,
|
input: {
|
||||||
|
stepId: step.id,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ function FlowStepContextMenu(props: FlowStepContextMenuProps): React.ReactElemen
|
|||||||
|
|
||||||
const deleteActionHandler = React.useCallback(async (event: React.SyntheticEvent) => {
|
const deleteActionHandler = React.useCallback(async (event: React.SyntheticEvent) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
await deleteStep({ variables: { id: stepId }});
|
await deleteStep({ variables: { input: { id: stepId } } });
|
||||||
}, [stepId]);
|
}, [stepId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@@ -39,8 +39,10 @@ function TestSubstep(props: TestSubstepProps): React.ReactElement {
|
|||||||
const handleSubmit = React.useCallback(() => {
|
const handleSubmit = React.useCallback(() => {
|
||||||
executeFlow({
|
executeFlow({
|
||||||
variables: {
|
variables: {
|
||||||
stepId: step.id,
|
input: {
|
||||||
}
|
stepId: step.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}, [onSubmit, step.id]);
|
}, [onSubmit, step.id]);
|
||||||
const onToggle = expanded ? onCollapse : onExpand;
|
const onToggle = expanded ? onCollapse : onExpand;
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
export const CREATE_AUTH_DATA = gql`
|
export const CREATE_AUTH_DATA = gql`
|
||||||
mutation createAuthData($id: String!) {
|
mutation CreateAuthData($input: CreateAuthDataInput) {
|
||||||
createAuthData(id: $id) {
|
createAuthData(input: $input) {
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,10 +2,9 @@ import { gql } from '@apollo/client';
|
|||||||
|
|
||||||
export const CREATE_CONNECTION = gql`
|
export const CREATE_CONNECTION = gql`
|
||||||
mutation CreateConnection(
|
mutation CreateConnection(
|
||||||
$key: AvailableAppsEnumType!
|
$input: CreateConnectionInput
|
||||||
$formattedData: JSONObject!
|
|
||||||
) {
|
) {
|
||||||
createConnection(key: $key, formattedData: $formattedData) {
|
createConnection(input: $input) {
|
||||||
id
|
id
|
||||||
key
|
key
|
||||||
verified
|
verified
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
export const CREATE_FLOW = gql`
|
export const CREATE_FLOW = gql`
|
||||||
mutation createFlow($input: FlowInput) {
|
mutation CreateFlow($input: CreateFlowInput) {
|
||||||
createFlow(input: $input) {
|
createFlow(input: $input) {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
export const CREATE_STEP = gql`
|
export const CREATE_STEP = gql`
|
||||||
mutation CreateStep($input: StepInput!) {
|
mutation CreateStep($input: CreateStepInput) {
|
||||||
createStep(input: $input) {
|
createStep(input: $input) {
|
||||||
id
|
id
|
||||||
type
|
type
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
export const DELETE_CONNECTION = gql`
|
export const DELETE_CONNECTION = gql`
|
||||||
mutation DeleteConnection($id: String!) {
|
mutation DeleteConnection($input: DeleteConnectionInput) {
|
||||||
deleteConnection(id: $id)
|
deleteConnection(input: $input)
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
export const DELETE_STEP = gql`
|
export const DELETE_STEP = gql`
|
||||||
mutation DeleteStep($id: String!) {
|
mutation DeleteStep($input: DeleteStepInput) {
|
||||||
deleteStep(id: $id) {
|
deleteStep(input: $input) {
|
||||||
id
|
id
|
||||||
flow {
|
flow {
|
||||||
id
|
id
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
export const EXECUTE_FLOW = gql`
|
export const EXECUTE_FLOW = gql`
|
||||||
mutation ExecuteFlow($stepId: String!) {
|
mutation ExecuteFlow($input: ExecuteFlowInput) {
|
||||||
executeFlow(stepId: $stepId) {
|
executeFlow(input: $input) {
|
||||||
step {
|
step {
|
||||||
id
|
id
|
||||||
status
|
status
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
export const RESET_CONNECTION = gql`
|
export const RESET_CONNECTION = gql`
|
||||||
mutation ResetConnection($id: String!) {
|
mutation ResetConnection($input: ResetConnectionInput) {
|
||||||
resetConnection(id: $id) {
|
resetConnection(input: $input) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
export const UPDATE_CONNECTION = gql`
|
export const UPDATE_CONNECTION = gql`
|
||||||
mutation UpdateConnection($id: String!, $formattedData: JSONObject!) {
|
mutation UpdateConnection($input: UpdateConnectionInput) {
|
||||||
updateConnection(id: $id, formattedData: $formattedData) {
|
updateConnection(input: $input) {
|
||||||
id
|
id
|
||||||
key
|
key
|
||||||
verified
|
verified
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
export const UPDATE_FLOW = gql`
|
export const UPDATE_FLOW = gql`
|
||||||
mutation UpdateFlow($id: String!, $name: String!) {
|
mutation UpdateFlow($input: UpdateFlowInput) {
|
||||||
updateFlow(id: $id, name: $name) {
|
updateFlow(input: $input) {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
export const UPDATE_STEP = gql`
|
export const UPDATE_STEP = gql`
|
||||||
mutation UpdateStep($input: StepInput!) {
|
mutation UpdateStep($input: UpdateStepInput) {
|
||||||
updateStep(input: $input) {
|
updateStep(input: $input) {
|
||||||
id
|
id
|
||||||
type
|
type
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
export const VERIFY_CONNECTION = gql`
|
export const VERIFY_CONNECTION = gql`
|
||||||
mutation VerifyConnection($id: String!) {
|
mutation VerifyConnection($input: VerifyConnectionInput) {
|
||||||
verifyConnection(id: $id) {
|
verifyConnection(input: $input) {
|
||||||
id
|
id
|
||||||
verified
|
verified
|
||||||
formattedData {
|
formattedData {
|
||||||
|
@@ -10,7 +10,7 @@ enum AuthenticationSteps {
|
|||||||
|
|
||||||
const processMutation = async (step: IAuthenticationStep, variables: IJSONObject) => {
|
const processMutation = async (step: IAuthenticationStep, variables: IJSONObject) => {
|
||||||
const mutation = MUTATIONS[step.name];
|
const mutation = MUTATIONS[step.name];
|
||||||
const mutationResponse = await apolloClient.mutate({ mutation, variables });
|
const mutationResponse = await apolloClient.mutate({ mutation, variables: { input: variables } });
|
||||||
const responseData = mutationResponse.data[step.name];
|
const responseData = mutationResponse.data[step.name];
|
||||||
|
|
||||||
return responseData;
|
return responseData;
|
||||||
|
Reference in New Issue
Block a user