Handle undefined attributes in records resolver (#61)
Some checks failed
Publish ApplicationRecord to Registry / cns_publish (release) Failing after 1m31s
Publish npm package to gitea / npm_publish (18.x) (release) Successful in 3m20s

Part of [Create a public laconicd testnet](https://www.notion.so/Create-a-public-laconicd-testnet-896a11bdd8094eff8f1b49c0be0ca3b8)

Handles the error in `LOOKUP` tab in the console:
```bash
Error: Cannot destructure property 'limit' of 'attributes' as it is undefined.
```

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: #61
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
Prathamesh Musale 2024-10-23 08:00:12 +00:00 committed by nabarun
parent 139fb37bef
commit 1e1149eb78
2 changed files with 70 additions and 78 deletions

View File

@ -11,8 +11,8 @@ import Button from '@material-ui/core/Button';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import TableBody from '@material-ui/core/TableBody';
import TableFooter from '@material-ui/core/TableFooter';
import TablePagination from '@material-ui/core/TablePagination';
import { Paper, TableContainer, } from '@material-ui/core';
import WNS_RECORDS from '../../../gql/wns_records.graphql';
@ -108,6 +108,10 @@ const RegistryRecords = ({ type }) => {
};
return (
<Paper style={{
width: '100%',
}}>
<TableContainer>
<Table>
<TableHead>
<TableRow>
@ -121,8 +125,7 @@ const RegistryRecords = ({ type }) => {
</TableRow>
</TableHead>
<TableBody>
{records.sort(sorter)
.map((record) => {
{records.sort(sorter).map((record) => {
const { id, names, createTime, attributes: { type, name: displayName, fileName, version, description, service, package: pkg } } = record;
let pkgLink;
@ -150,28 +153,19 @@ const RegistryRecords = ({ type }) => {
<TableCell monospace>
{appLinks || (names || []).map(name => <div key={name}>{name}</div>)}
</TableCell>
<TableCell monospace>
{version}
</TableCell>
<TableCell>
{displayName || service || fileName || description}
</TableCell>
<TableCell>
{moment.utc(createTime).fromNow()}
</TableCell>
<TableCell monospace>
{pkgLink}
</TableCell>
<TableCell monospace>{version}</TableCell>
<TableCell>{displayName || service || fileName || description}</TableCell>
<TableCell>{moment.utc(createTime).fromNow()}</TableCell>
<TableCell monospace>{pkgLink}</TableCell>
<TableCell>
<QueryLink config={config} id={id} icon />
</TableCell>
</TableRow>
);
}
)}
})}
</TableBody>
<TableFooter>
<TableRow>
</Table>
</TableContainer>
<TablePagination
component="td"
rowsPerPageOptions={[5, 10, 25]}
@ -185,9 +179,7 @@ const RegistryRecords = ({ type }) => {
disabled: records.length < rowsPerPage,
}}
/>
</TableRow>
</TableFooter>
</Table>
</Paper>
);
};

View File

@ -46,7 +46,7 @@ export const createResolvers = config => {
wns_records: async (_, { attributes }) => {
log('WNS records...');
const {limit, offset, ...queryAttributes } = attributes;
const {limit, offset, ...queryAttributes } = attributes || {};
const data = await registry.queryRecords(queryAttributes, false, false, limit, offset);
return {