2020-09-20 22:30:17 +02:00
|
|
|
import { gql, useQuery } from "@apollo/client";
|
|
|
|
import { Box, Grid, Paper } from "@material-ui/core";
|
|
|
|
|
|
|
|
import ResponseDetail from "./ResponseDetail";
|
|
|
|
import RequestDetail from "./RequestDetail";
|
|
|
|
|
|
|
|
const HTTP_REQUEST_LOG = gql`
|
|
|
|
query HttpRequestLog($id: ID!) {
|
|
|
|
httpRequestLog(id: $id) {
|
|
|
|
id
|
|
|
|
method
|
|
|
|
url
|
2020-09-21 22:27:10 +02:00
|
|
|
proto
|
2020-09-20 22:30:17 +02:00
|
|
|
body
|
|
|
|
response {
|
|
|
|
proto
|
|
|
|
status
|
|
|
|
statusCode
|
|
|
|
body
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
requestId: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
function LogDetail({ requestId: id }: Props): JSX.Element {
|
|
|
|
const { loading, error, data } = useQuery(HTTP_REQUEST_LOG, {
|
|
|
|
variables: { id },
|
|
|
|
});
|
|
|
|
|
2020-09-21 22:27:10 +02:00
|
|
|
if (loading) return <div>"Loading..."</div>;
|
|
|
|
if (error) return <div>`Error: ${error.message}`</div>;
|
2020-09-20 22:30:17 +02:00
|
|
|
|
2020-09-21 22:27:10 +02:00
|
|
|
const { method, url, proto, body, response } = data.httpRequestLog;
|
2020-09-20 22:30:17 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Grid container item spacing={2}>
|
|
|
|
<Grid item xs={6}>
|
2020-09-21 21:46:44 +02:00
|
|
|
<Box component={Paper} maxHeight="60vh" overflow="scroll">
|
2020-09-21 22:27:10 +02:00
|
|
|
<RequestDetail request={{ method, url, proto, body }} />
|
2020-09-20 22:30:17 +02:00
|
|
|
</Box>
|
|
|
|
</Grid>
|
|
|
|
<Grid item xs={6}>
|
2020-09-21 21:46:44 +02:00
|
|
|
{response && (
|
|
|
|
<Box component={Paper} maxHeight="65vh" overflow="scroll">
|
|
|
|
<ResponseDetail response={response} />
|
|
|
|
</Box>
|
|
|
|
)}
|
2020-09-20 22:30:17 +02:00
|
|
|
</Grid>
|
|
|
|
</Grid>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default LogDetail;
|