mirror of
https://github.com/dstotijn/hetty.git
synced 2025-07-01 18:47:29 -04:00
Add support for intercepting HTTP responses
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import CancelIcon from "@mui/icons-material/Cancel";
|
||||
import DownloadIcon from "@mui/icons-material/Download";
|
||||
import SendIcon from "@mui/icons-material/Send";
|
||||
import SettingsIcon from "@mui/icons-material/Settings";
|
||||
import { Alert, Box, Button, CircularProgress, IconButton, Tooltip, Typography } from "@mui/material";
|
||||
@ -9,15 +10,17 @@ import { useInterceptedRequests } from "lib/InterceptedRequestsContext";
|
||||
import { KeyValuePair, sortKeyValuePairs } from "lib/components/KeyValuePair";
|
||||
import Link from "lib/components/Link";
|
||||
import RequestTabs from "lib/components/RequestTabs";
|
||||
import Response from "lib/components/Response";
|
||||
import SplitPane from "lib/components/SplitPane";
|
||||
import ResponseStatus from "lib/components/ResponseStatus";
|
||||
import ResponseTabs from "lib/components/ResponseTabs";
|
||||
import UrlBar, { HttpMethod, HttpProto, httpProtoMap } from "lib/components/UrlBar";
|
||||
import {
|
||||
HttpProtocol,
|
||||
HttpRequest,
|
||||
useCancelRequestMutation,
|
||||
useCancelResponseMutation,
|
||||
useGetInterceptedRequestQuery,
|
||||
useModifyRequestMutation,
|
||||
useModifyResponseMutation,
|
||||
} from "lib/graphql/generated";
|
||||
import { queryParamsFromURL } from "lib/queryParamsFromURL";
|
||||
import updateKeyPairItem from "lib/updateKeyPairItem";
|
||||
@ -43,8 +46,10 @@ function EditRequest(): JSX.Element {
|
||||
const [url, setURL] = useState("");
|
||||
const [proto, setProto] = useState(HttpProto.Http20);
|
||||
const [queryParams, setQueryParams] = useState<KeyValuePair[]>([{ key: "", value: "" }]);
|
||||
const [headers, setHeaders] = useState<KeyValuePair[]>([{ key: "", value: "" }]);
|
||||
const [body, setBody] = useState("");
|
||||
const [reqHeaders, setReqHeaders] = useState<KeyValuePair[]>([{ key: "", value: "" }]);
|
||||
const [resHeaders, setResHeaders] = useState<KeyValuePair[]>([{ key: "", value: "" }]);
|
||||
const [reqBody, setReqBody] = useState("");
|
||||
const [resBody, setResBody] = useState("");
|
||||
|
||||
const handleQueryParamChange = (key: string, value: string, idx: number) => {
|
||||
setQueryParams((prev) => {
|
||||
@ -61,11 +66,18 @@ function EditRequest(): JSX.Element {
|
||||
});
|
||||
};
|
||||
|
||||
const handleHeaderChange = (key: string, value: string, idx: number) => {
|
||||
setHeaders((prev) => updateKeyPairItem(key, value, idx, prev));
|
||||
const handleReqHeaderChange = (key: string, value: string, idx: number) => {
|
||||
setReqHeaders((prev) => updateKeyPairItem(key, value, idx, prev));
|
||||
};
|
||||
const handleHeaderDelete = (idx: number) => {
|
||||
setHeaders((prev) => prev.slice(0, idx).concat(prev.slice(idx + 1, prev.length)));
|
||||
const handleReqHeaderDelete = (idx: number) => {
|
||||
setReqHeaders((prev) => prev.slice(0, idx).concat(prev.slice(idx + 1, prev.length)));
|
||||
};
|
||||
|
||||
const handleResHeaderChange = (key: string, value: string, idx: number) => {
|
||||
setResHeaders((prev) => updateKeyPairItem(key, value, idx, prev));
|
||||
};
|
||||
const handleResHeaderDelete = (idx: number) => {
|
||||
setResHeaders((prev) => prev.slice(0, idx).concat(prev.slice(idx + 1, prev.length)));
|
||||
};
|
||||
|
||||
const handleURLChange = (url: string) => {
|
||||
@ -93,63 +105,95 @@ function EditRequest(): JSX.Element {
|
||||
|
||||
setURL(interceptedRequest.url);
|
||||
setMethod(interceptedRequest.method);
|
||||
setBody(interceptedRequest.body || "");
|
||||
setReqBody(interceptedRequest.body || "");
|
||||
|
||||
const newQueryParams = queryParamsFromURL(interceptedRequest.url);
|
||||
// Push empty row.
|
||||
newQueryParams.push({ key: "", value: "" });
|
||||
setQueryParams(newQueryParams);
|
||||
|
||||
const newHeaders = sortKeyValuePairs(interceptedRequest.headers || []);
|
||||
setHeaders([...newHeaders.map(({ key, value }) => ({ key, value })), { key: "", value: "" }]);
|
||||
const newReqHeaders = sortKeyValuePairs(interceptedRequest.headers || []);
|
||||
setReqHeaders([...newReqHeaders.map(({ key, value }) => ({ key, value })), { key: "", value: "" }]);
|
||||
|
||||
setResBody(interceptedRequest.response?.body || "");
|
||||
const newResHeaders = sortKeyValuePairs(interceptedRequest.response?.headers || []);
|
||||
setResHeaders([...newResHeaders.map(({ key, value }) => ({ key, value })), { key: "", value: "" }]);
|
||||
},
|
||||
});
|
||||
const interceptedReq = reqId ? getReqResult?.data?.interceptedRequest : undefined;
|
||||
const interceptedReq =
|
||||
reqId && !getReqResult?.data?.interceptedRequest?.response ? getReqResult?.data?.interceptedRequest : undefined;
|
||||
const interceptedRes = reqId ? getReqResult?.data?.interceptedRequest?.response : undefined;
|
||||
|
||||
const [modifyRequest, modifyResult] = useModifyRequestMutation();
|
||||
const [cancelRequest, cancelResult] = useCancelRequestMutation();
|
||||
const [modifyRequest, modifyReqResult] = useModifyRequestMutation();
|
||||
const [cancelRequest, cancelReqResult] = useCancelRequestMutation();
|
||||
|
||||
const [modifyResponse, modifyResResult] = useModifyResponseMutation();
|
||||
const [cancelResponse, cancelResResult] = useCancelResponseMutation();
|
||||
|
||||
const onActionCompleted = () => {
|
||||
setURL("");
|
||||
setMethod(HttpMethod.Get);
|
||||
setBody("");
|
||||
setReqBody("");
|
||||
setQueryParams([]);
|
||||
setHeaders([]);
|
||||
setReqHeaders([]);
|
||||
router.replace(`/proxy/intercept`);
|
||||
};
|
||||
|
||||
const handleFormSubmit: React.FormEventHandler = (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (!interceptedReq) {
|
||||
return;
|
||||
if (interceptedReq) {
|
||||
modifyRequest({
|
||||
variables: {
|
||||
request: {
|
||||
id: interceptedReq.id,
|
||||
url,
|
||||
method,
|
||||
proto: httpProtoMap.get(proto) || HttpProtocol.Http20,
|
||||
headers: reqHeaders.filter((kv) => kv.key !== ""),
|
||||
body: reqBody || undefined,
|
||||
},
|
||||
},
|
||||
update(cache) {
|
||||
cache.modify({
|
||||
fields: {
|
||||
interceptedRequests(existing: HttpRequest[], { readField }) {
|
||||
return existing.filter((ref) => interceptedReq.id !== readField("id", ref));
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
onCompleted: onActionCompleted,
|
||||
});
|
||||
}
|
||||
|
||||
modifyRequest({
|
||||
variables: {
|
||||
request: {
|
||||
id: interceptedReq.id,
|
||||
url,
|
||||
method,
|
||||
proto: httpProtoMap.get(proto) || HttpProtocol.Http20,
|
||||
headers: headers.filter((kv) => kv.key !== ""),
|
||||
body: body || undefined,
|
||||
},
|
||||
},
|
||||
update(cache) {
|
||||
cache.modify({
|
||||
fields: {
|
||||
interceptedRequests(existing: HttpRequest[], { readField }) {
|
||||
return existing.filter((ref) => interceptedReq.id !== readField("id", ref));
|
||||
},
|
||||
if (interceptedRes) {
|
||||
modifyResponse({
|
||||
variables: {
|
||||
response: {
|
||||
requestID: interceptedRes.id,
|
||||
proto: interceptedRes.proto, // TODO: Allow modifying
|
||||
statusCode: interceptedRes.statusCode, // TODO: Allow modifying
|
||||
statusReason: interceptedRes.statusReason, // TODO: Allow modifying
|
||||
headers: resHeaders.filter((kv) => kv.key !== ""),
|
||||
body: resBody || undefined,
|
||||
},
|
||||
});
|
||||
},
|
||||
onCompleted: onActionCompleted,
|
||||
});
|
||||
},
|
||||
update(cache) {
|
||||
cache.modify({
|
||||
fields: {
|
||||
interceptedRequests(existing: HttpRequest[], { readField }) {
|
||||
return existing.filter((ref) => interceptedRes.id !== readField("id", ref));
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
onCompleted: onActionCompleted,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancelClick = () => {
|
||||
const handleReqCancelClick = () => {
|
||||
if (!interceptedReq) {
|
||||
return;
|
||||
}
|
||||
@ -171,6 +215,28 @@ function EditRequest(): JSX.Element {
|
||||
});
|
||||
};
|
||||
|
||||
const handleResCancelClick = () => {
|
||||
if (!interceptedRes) {
|
||||
return;
|
||||
}
|
||||
|
||||
cancelResponse({
|
||||
variables: {
|
||||
requestID: interceptedRes.id,
|
||||
},
|
||||
update(cache) {
|
||||
cache.modify({
|
||||
fields: {
|
||||
interceptedRequests(existing: HttpRequest[], { readField }) {
|
||||
return existing.filter((ref) => interceptedRes.id !== readField("id", ref));
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
onCompleted: onActionCompleted,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Box display="flex" flexDirection="column" height="100%" gap={2}>
|
||||
<Box component="form" autoComplete="off" onSubmit={handleFormSubmit}>
|
||||
@ -184,64 +250,114 @@ function EditRequest(): JSX.Element {
|
||||
onProtoChange={interceptedReq ? setProto : undefined}
|
||||
sx={{ flex: "1 auto" }}
|
||||
/>
|
||||
<Button
|
||||
variant="contained"
|
||||
disableElevation
|
||||
type="submit"
|
||||
disabled={!interceptedReq || modifyResult.loading || cancelResult.loading}
|
||||
startIcon={modifyResult.loading ? <CircularProgress size={22} /> : <SendIcon />}
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="error"
|
||||
disableElevation
|
||||
onClick={handleCancelClick}
|
||||
disabled={!interceptedReq || modifyResult.loading || cancelResult.loading}
|
||||
startIcon={cancelResult.loading ? <CircularProgress size={22} /> : <CancelIcon />}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
{!interceptedRes && (
|
||||
<>
|
||||
<Button
|
||||
variant="contained"
|
||||
disableElevation
|
||||
type="submit"
|
||||
disabled={!interceptedReq || modifyReqResult.loading || cancelReqResult.loading}
|
||||
startIcon={modifyReqResult.loading ? <CircularProgress size={22} /> : <SendIcon />}
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="error"
|
||||
disableElevation
|
||||
onClick={handleReqCancelClick}
|
||||
disabled={!interceptedReq || modifyReqResult.loading || cancelReqResult.loading}
|
||||
startIcon={cancelReqResult.loading ? <CircularProgress size={22} /> : <CancelIcon />}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{interceptedRes && (
|
||||
<>
|
||||
<Button
|
||||
variant="contained"
|
||||
disableElevation
|
||||
type="submit"
|
||||
disabled={modifyResResult.loading || cancelResResult.loading}
|
||||
endIcon={modifyResResult.loading ? <CircularProgress size={22} /> : <DownloadIcon />}
|
||||
>
|
||||
Receive
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="error"
|
||||
disableElevation
|
||||
onClick={handleResCancelClick}
|
||||
disabled={modifyResResult.loading || cancelResResult.loading}
|
||||
endIcon={cancelResResult.loading ? <CircularProgress size={22} /> : <CancelIcon />}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<Tooltip title="Intercept settings">
|
||||
<IconButton LinkComponent={Link} href="/settings#intercept">
|
||||
<SettingsIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
{modifyResult.error && (
|
||||
{modifyReqResult.error && (
|
||||
<Alert severity="error" sx={{ mt: 1 }}>
|
||||
{modifyResult.error.message}
|
||||
{modifyReqResult.error.message}
|
||||
</Alert>
|
||||
)}
|
||||
{cancelResult.error && (
|
||||
{cancelReqResult.error && (
|
||||
<Alert severity="error" sx={{ mt: 1 }}>
|
||||
{cancelResult.error.message}
|
||||
{cancelReqResult.error.message}
|
||||
</Alert>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
<Box flex="1 auto" position="relative">
|
||||
<SplitPane split="vertical" size={"50%"}>
|
||||
<Box sx={{ height: "100%", mr: 2, pb: 2, position: "relative" }}>
|
||||
<Box flex="1 auto" overflow="scroll">
|
||||
{interceptedReq && (
|
||||
<Box sx={{ height: "100%", pb: 2 }}>
|
||||
<Typography variant="overline" color="textSecondary" sx={{ position: "absolute", right: 0, mt: 1.2 }}>
|
||||
Request
|
||||
</Typography>
|
||||
<RequestTabs
|
||||
queryParams={interceptedReq ? queryParams : []}
|
||||
headers={interceptedReq ? headers : []}
|
||||
body={body}
|
||||
headers={interceptedReq ? reqHeaders : []}
|
||||
body={reqBody}
|
||||
onQueryParamChange={interceptedReq ? handleQueryParamChange : undefined}
|
||||
onQueryParamDelete={interceptedReq ? handleQueryParamDelete : undefined}
|
||||
onHeaderChange={interceptedReq ? handleHeaderChange : undefined}
|
||||
onHeaderDelete={interceptedReq ? handleHeaderDelete : undefined}
|
||||
onBodyChange={interceptedReq ? setBody : undefined}
|
||||
onHeaderChange={interceptedReq ? handleReqHeaderChange : undefined}
|
||||
onHeaderDelete={interceptedReq ? handleReqHeaderDelete : undefined}
|
||||
onBodyChange={interceptedReq ? setReqBody : undefined}
|
||||
/>
|
||||
</Box>
|
||||
<Box sx={{ height: "100%", position: "relative", ml: 2, pb: 2 }}>
|
||||
<Response response={null} />
|
||||
)}
|
||||
{interceptedRes && (
|
||||
<Box sx={{ height: "100%", pb: 2 }}>
|
||||
<Box sx={{ position: "absolute", right: 0, mt: 1.4 }}>
|
||||
<Typography variant="overline" color="textSecondary" sx={{ float: "right", ml: 3 }}>
|
||||
Response
|
||||
</Typography>
|
||||
{interceptedRes && (
|
||||
<Box sx={{ float: "right", mt: 0.2 }}>
|
||||
<ResponseStatus
|
||||
proto={interceptedRes.proto}
|
||||
statusCode={interceptedRes.statusCode}
|
||||
statusReason={interceptedRes.statusReason}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
<ResponseTabs
|
||||
headers={interceptedRes ? resHeaders : []}
|
||||
body={resBody}
|
||||
onHeaderChange={interceptedRes ? handleResHeaderChange : undefined}
|
||||
onHeaderDelete={interceptedRes ? handleResHeaderDelete : undefined}
|
||||
onBodyChange={interceptedRes ? setResBody : undefined}
|
||||
hasResponse={interceptedRes !== undefined && interceptedRes !== null}
|
||||
/>
|
||||
</Box>
|
||||
</SplitPane>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
|
@ -0,0 +1,5 @@
|
||||
mutation CancelResponse($requestID: ID!) {
|
||||
cancelResponse(requestID: $requestID) {
|
||||
success
|
||||
}
|
||||
}
|
@ -9,5 +9,16 @@ query GetInterceptedRequest($id: ID!) {
|
||||
value
|
||||
}
|
||||
body
|
||||
response {
|
||||
id
|
||||
proto
|
||||
statusCode
|
||||
statusReason
|
||||
headers {
|
||||
key
|
||||
value
|
||||
}
|
||||
body
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
mutation ModifyResponse($response: ModifyResponseInput!) {
|
||||
modifyResponse(response: $response) {
|
||||
success
|
||||
}
|
||||
}
|
@ -2,13 +2,16 @@ import { TabContext, TabList, TabPanel } from "@mui/lab";
|
||||
import { Box, Paper, Tab, Typography } from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
|
||||
import { KeyValuePairTable, KeyValuePair, KeyValuePairTableProps } from "./KeyValuePair";
|
||||
|
||||
import Editor from "lib/components/Editor";
|
||||
import { KeyValuePairTable } from "lib/components/KeyValuePair";
|
||||
import { HttpResponseLog } from "lib/graphql/generated";
|
||||
|
||||
interface ResponseTabsProps {
|
||||
headers: HttpResponseLog["headers"];
|
||||
body: HttpResponseLog["body"];
|
||||
headers: KeyValuePair[];
|
||||
onHeaderChange?: KeyValuePairTableProps["onChange"];
|
||||
onHeaderDelete?: KeyValuePairTableProps["onDelete"];
|
||||
body?: string | null;
|
||||
onBodyChange?: (value: string) => void;
|
||||
hasResponse: boolean;
|
||||
}
|
||||
|
||||
@ -24,7 +27,7 @@ const reqNotSent = (
|
||||
);
|
||||
|
||||
function ResponseTabs(props: ResponseTabsProps): JSX.Element {
|
||||
const { headers, body, hasResponse } = props;
|
||||
const { headers, onHeaderChange, onHeaderDelete, body, onBodyChange, hasResponse } = props;
|
||||
const [tabValue, setTabValue] = useState(TabValue.Body);
|
||||
|
||||
const contentType = headers.find((header) => header.key.toLowerCase() === "content-type")?.value;
|
||||
@ -33,6 +36,8 @@ function ResponseTabs(props: ResponseTabsProps): JSX.Element {
|
||||
textTransform: "none",
|
||||
};
|
||||
|
||||
const headersLength = onHeaderChange ? headers.length - 1 : headers.length;
|
||||
|
||||
return (
|
||||
<Box height="100%" sx={{ display: "flex", flexDirection: "column" }}>
|
||||
<TabContext value={tabValue}>
|
||||
@ -43,20 +48,25 @@ function ResponseTabs(props: ResponseTabsProps): JSX.Element {
|
||||
label={"Body" + (body?.length ? ` (${body.length} byte` + (body.length > 1 ? "s" : "") + ")" : "")}
|
||||
sx={tabSx}
|
||||
/>
|
||||
<Tab
|
||||
value={TabValue.Headers}
|
||||
label={"Headers" + (headers.length ? ` (${headers.length})` : "")}
|
||||
sx={tabSx}
|
||||
/>
|
||||
<Tab value={TabValue.Headers} label={"Headers" + (headersLength ? ` (${headersLength})` : "")} sx={tabSx} />
|
||||
</TabList>
|
||||
</Box>
|
||||
<Box flex="1 auto" overflow="hidden">
|
||||
<TabPanel value={TabValue.Body} sx={{ p: 0, height: "100%" }}>
|
||||
{body && <Editor content={body} contentType={contentType} />}
|
||||
{hasResponse && (
|
||||
<Editor
|
||||
content={body || ""}
|
||||
onChange={(value) => {
|
||||
onBodyChange && onBodyChange(value || "");
|
||||
}}
|
||||
monacoOptions={{ readOnly: onBodyChange === undefined }}
|
||||
contentType={contentType}
|
||||
/>
|
||||
)}
|
||||
{!hasResponse && reqNotSent}
|
||||
</TabPanel>
|
||||
<TabPanel value={TabValue.Headers} sx={{ p: 0, height: "100%", overflow: "scroll" }}>
|
||||
{headers.length > 0 && <KeyValuePairTable items={headers} />}
|
||||
{hasResponse && <KeyValuePairTable items={headers} onChange={onHeaderChange} onDelete={onHeaderDelete} />}
|
||||
{!hasResponse && reqNotSent}
|
||||
</TabPanel>
|
||||
</Box>
|
||||
|
@ -23,6 +23,11 @@ export type CancelRequestResult = {
|
||||
success: Scalars['Boolean'];
|
||||
};
|
||||
|
||||
export type CancelResponseResult = {
|
||||
__typename?: 'CancelResponseResult';
|
||||
success: Scalars['Boolean'];
|
||||
};
|
||||
|
||||
export type ClearHttpRequestLogResult = {
|
||||
__typename?: 'ClearHTTPRequestLogResult';
|
||||
success: Scalars['Boolean'];
|
||||
@ -79,6 +84,7 @@ export type HttpRequest = {
|
||||
id: Scalars['ID'];
|
||||
method: HttpMethod;
|
||||
proto: HttpProtocol;
|
||||
response?: Maybe<HttpResponse>;
|
||||
url: Scalars['URL'];
|
||||
};
|
||||
|
||||
@ -105,6 +111,17 @@ export type HttpRequestLogFilterInput = {
|
||||
searchExpression?: InputMaybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type HttpResponse = {
|
||||
__typename?: 'HttpResponse';
|
||||
body?: Maybe<Scalars['String']>;
|
||||
headers: Array<HttpHeader>;
|
||||
/** Will be the same ID as its related request ID. */
|
||||
id: Scalars['ID'];
|
||||
proto: HttpProtocol;
|
||||
statusCode: Scalars['Int'];
|
||||
statusReason: Scalars['String'];
|
||||
};
|
||||
|
||||
export type HttpResponseLog = {
|
||||
__typename?: 'HttpResponseLog';
|
||||
body?: Maybe<Scalars['String']>;
|
||||
@ -127,6 +144,7 @@ export type ModifyRequestInput = {
|
||||
headers?: InputMaybe<Array<HttpHeaderInput>>;
|
||||
id: Scalars['ID'];
|
||||
method: HttpMethod;
|
||||
modifyResponse?: InputMaybe<Scalars['Boolean']>;
|
||||
proto: HttpProtocol;
|
||||
url: Scalars['URL'];
|
||||
};
|
||||
@ -136,9 +154,24 @@ export type ModifyRequestResult = {
|
||||
success: Scalars['Boolean'];
|
||||
};
|
||||
|
||||
export type ModifyResponseInput = {
|
||||
body?: InputMaybe<Scalars['String']>;
|
||||
headers?: InputMaybe<Array<HttpHeaderInput>>;
|
||||
proto: HttpProtocol;
|
||||
requestID: Scalars['ID'];
|
||||
statusCode: Scalars['Int'];
|
||||
statusReason: Scalars['String'];
|
||||
};
|
||||
|
||||
export type ModifyResponseResult = {
|
||||
__typename?: 'ModifyResponseResult';
|
||||
success: Scalars['Boolean'];
|
||||
};
|
||||
|
||||
export type Mutation = {
|
||||
__typename?: 'Mutation';
|
||||
cancelRequest: CancelRequestResult;
|
||||
cancelResponse: CancelResponseResult;
|
||||
clearHTTPRequestLog: ClearHttpRequestLogResult;
|
||||
closeProject: CloseProjectResult;
|
||||
createOrUpdateSenderRequest: SenderRequest;
|
||||
@ -147,6 +180,7 @@ export type Mutation = {
|
||||
deleteProject: DeleteProjectResult;
|
||||
deleteSenderRequests: DeleteSenderRequestsResult;
|
||||
modifyRequest: ModifyRequestResult;
|
||||
modifyResponse: ModifyResponseResult;
|
||||
openProject?: Maybe<Project>;
|
||||
sendRequest: SenderRequest;
|
||||
setHttpRequestLogFilter?: Maybe<HttpRequestLogFilter>;
|
||||
@ -161,6 +195,11 @@ export type MutationCancelRequestArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type MutationCancelResponseArgs = {
|
||||
requestID: Scalars['ID'];
|
||||
};
|
||||
|
||||
|
||||
export type MutationCreateOrUpdateSenderRequestArgs = {
|
||||
request: SenderRequestInput;
|
||||
};
|
||||
@ -186,6 +225,11 @@ export type MutationModifyRequestArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type MutationModifyResponseArgs = {
|
||||
response: ModifyResponseInput;
|
||||
};
|
||||
|
||||
|
||||
export type MutationOpenProjectArgs = {
|
||||
id: Scalars['ID'];
|
||||
};
|
||||
@ -326,12 +370,19 @@ export type CancelRequestMutationVariables = Exact<{
|
||||
|
||||
export type CancelRequestMutation = { __typename?: 'Mutation', cancelRequest: { __typename?: 'CancelRequestResult', success: boolean } };
|
||||
|
||||
export type CancelResponseMutationVariables = Exact<{
|
||||
requestID: Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type CancelResponseMutation = { __typename?: 'Mutation', cancelResponse: { __typename?: 'CancelResponseResult', success: boolean } };
|
||||
|
||||
export type GetInterceptedRequestQueryVariables = Exact<{
|
||||
id: Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetInterceptedRequestQuery = { __typename?: 'Query', interceptedRequest?: { __typename?: 'HttpRequest', id: string, url: any, method: HttpMethod, proto: HttpProtocol, body?: string | null, headers: Array<{ __typename?: 'HttpHeader', key: string, value: string }> } | null };
|
||||
export type GetInterceptedRequestQuery = { __typename?: 'Query', interceptedRequest?: { __typename?: 'HttpRequest', id: string, url: any, method: HttpMethod, proto: HttpProtocol, body?: string | null, headers: Array<{ __typename?: 'HttpHeader', key: string, value: string }>, response?: { __typename?: 'HttpResponse', id: string, proto: HttpProtocol, statusCode: number, statusReason: string, body?: string | null, headers: Array<{ __typename?: 'HttpHeader', key: string, value: string }> } | null } | null };
|
||||
|
||||
export type ModifyRequestMutationVariables = Exact<{
|
||||
request: ModifyRequestInput;
|
||||
@ -340,6 +391,13 @@ export type ModifyRequestMutationVariables = Exact<{
|
||||
|
||||
export type ModifyRequestMutation = { __typename?: 'Mutation', modifyRequest: { __typename?: 'ModifyRequestResult', success: boolean } };
|
||||
|
||||
export type ModifyResponseMutationVariables = Exact<{
|
||||
response: ModifyResponseInput;
|
||||
}>;
|
||||
|
||||
|
||||
export type ModifyResponseMutation = { __typename?: 'Mutation', modifyResponse: { __typename?: 'ModifyResponseResult', success: boolean } };
|
||||
|
||||
export type ActiveProjectQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
@ -460,7 +518,7 @@ export type UpdateInterceptSettingsMutation = { __typename?: 'Mutation', updateI
|
||||
export type GetInterceptedRequestsQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type GetInterceptedRequestsQuery = { __typename?: 'Query', interceptedRequests: Array<{ __typename?: 'HttpRequest', id: string, url: any, method: HttpMethod }> };
|
||||
export type GetInterceptedRequestsQuery = { __typename?: 'Query', interceptedRequests: Array<{ __typename?: 'HttpRequest', id: string, url: any, method: HttpMethod, response?: { __typename?: 'HttpResponse', statusCode: number, statusReason: string } | null }> };
|
||||
|
||||
|
||||
export const CancelRequestDocument = gql`
|
||||
@ -496,6 +554,39 @@ export function useCancelRequestMutation(baseOptions?: Apollo.MutationHookOption
|
||||
export type CancelRequestMutationHookResult = ReturnType<typeof useCancelRequestMutation>;
|
||||
export type CancelRequestMutationResult = Apollo.MutationResult<CancelRequestMutation>;
|
||||
export type CancelRequestMutationOptions = Apollo.BaseMutationOptions<CancelRequestMutation, CancelRequestMutationVariables>;
|
||||
export const CancelResponseDocument = gql`
|
||||
mutation CancelResponse($requestID: ID!) {
|
||||
cancelResponse(requestID: $requestID) {
|
||||
success
|
||||
}
|
||||
}
|
||||
`;
|
||||
export type CancelResponseMutationFn = Apollo.MutationFunction<CancelResponseMutation, CancelResponseMutationVariables>;
|
||||
|
||||
/**
|
||||
* __useCancelResponseMutation__
|
||||
*
|
||||
* To run a mutation, you first call `useCancelResponseMutation` within a React component and pass it any options that fit your needs.
|
||||
* When your component renders, `useCancelResponseMutation` returns a tuple that includes:
|
||||
* - A mutate function that you can call at any time to execute the mutation
|
||||
* - An object with fields that represent the current status of the mutation's execution
|
||||
*
|
||||
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
|
||||
*
|
||||
* @example
|
||||
* const [cancelResponseMutation, { data, loading, error }] = useCancelResponseMutation({
|
||||
* variables: {
|
||||
* requestID: // value for 'requestID'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useCancelResponseMutation(baseOptions?: Apollo.MutationHookOptions<CancelResponseMutation, CancelResponseMutationVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useMutation<CancelResponseMutation, CancelResponseMutationVariables>(CancelResponseDocument, options);
|
||||
}
|
||||
export type CancelResponseMutationHookResult = ReturnType<typeof useCancelResponseMutation>;
|
||||
export type CancelResponseMutationResult = Apollo.MutationResult<CancelResponseMutation>;
|
||||
export type CancelResponseMutationOptions = Apollo.BaseMutationOptions<CancelResponseMutation, CancelResponseMutationVariables>;
|
||||
export const GetInterceptedRequestDocument = gql`
|
||||
query GetInterceptedRequest($id: ID!) {
|
||||
interceptedRequest(id: $id) {
|
||||
@ -508,6 +599,17 @@ export const GetInterceptedRequestDocument = gql`
|
||||
value
|
||||
}
|
||||
body
|
||||
response {
|
||||
id
|
||||
proto
|
||||
statusCode
|
||||
statusReason
|
||||
headers {
|
||||
key
|
||||
value
|
||||
}
|
||||
body
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -572,6 +674,39 @@ export function useModifyRequestMutation(baseOptions?: Apollo.MutationHookOption
|
||||
export type ModifyRequestMutationHookResult = ReturnType<typeof useModifyRequestMutation>;
|
||||
export type ModifyRequestMutationResult = Apollo.MutationResult<ModifyRequestMutation>;
|
||||
export type ModifyRequestMutationOptions = Apollo.BaseMutationOptions<ModifyRequestMutation, ModifyRequestMutationVariables>;
|
||||
export const ModifyResponseDocument = gql`
|
||||
mutation ModifyResponse($response: ModifyResponseInput!) {
|
||||
modifyResponse(response: $response) {
|
||||
success
|
||||
}
|
||||
}
|
||||
`;
|
||||
export type ModifyResponseMutationFn = Apollo.MutationFunction<ModifyResponseMutation, ModifyResponseMutationVariables>;
|
||||
|
||||
/**
|
||||
* __useModifyResponseMutation__
|
||||
*
|
||||
* To run a mutation, you first call `useModifyResponseMutation` within a React component and pass it any options that fit your needs.
|
||||
* When your component renders, `useModifyResponseMutation` returns a tuple that includes:
|
||||
* - A mutate function that you can call at any time to execute the mutation
|
||||
* - An object with fields that represent the current status of the mutation's execution
|
||||
*
|
||||
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
|
||||
*
|
||||
* @example
|
||||
* const [modifyResponseMutation, { data, loading, error }] = useModifyResponseMutation({
|
||||
* variables: {
|
||||
* response: // value for 'response'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useModifyResponseMutation(baseOptions?: Apollo.MutationHookOptions<ModifyResponseMutation, ModifyResponseMutationVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useMutation<ModifyResponseMutation, ModifyResponseMutationVariables>(ModifyResponseDocument, options);
|
||||
}
|
||||
export type ModifyResponseMutationHookResult = ReturnType<typeof useModifyResponseMutation>;
|
||||
export type ModifyResponseMutationResult = Apollo.MutationResult<ModifyResponseMutation>;
|
||||
export type ModifyResponseMutationOptions = Apollo.BaseMutationOptions<ModifyResponseMutation, ModifyResponseMutationVariables>;
|
||||
export const ActiveProjectDocument = gql`
|
||||
query ActiveProject {
|
||||
activeProject {
|
||||
@ -1283,6 +1418,10 @@ export const GetInterceptedRequestsDocument = gql`
|
||||
id
|
||||
url
|
||||
method
|
||||
response {
|
||||
statusCode
|
||||
statusReason
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
@ -3,5 +3,9 @@ query GetInterceptedRequests {
|
||||
id
|
||||
url
|
||||
method
|
||||
response {
|
||||
statusCode
|
||||
statusReason
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user