cryostatio / cryostatio/cryostat-web

[Task] Refactor to eliminate redundant queries

Open
#620 0 comments 0 reactions 0 assignees View on GitHub
chore
Dominant language
TypeScript
Stars
13
Forks
21
Avg merge
1d 14h
Merged PRs (30d)
35

Description

For example, when loading the Recordings view, the Active subview issues a request like this:

```
http://localhost:8181/api/v1/targets/service%3Ajmx%3Armi%3A%2F%2F%2Fjndi%2Frmi%3A%2F%2Fcarbon%3A9091%2Fjmxrmi/recordings
```

and the Archived subview issues a GraphQL request like this:

```json
{
"query": " query ArchivedRecordingsForTarget($connectUrl: String) { archivedRecordings(filter: { sourceTarget: $connectUrl }) { data { name downloadUrl reportUrl metadata { labels } size } } }",
"variables": {
"connectUrl": "service:jmx:rmi:///jndi/rmi://carbon:9091/jmxrmi"
}
}
```

separately.

All of the needed content could be loaded by a single GraphQL request:

```json
{
"query": "query RecordingsForTarget($connectUrl: String) { targetNodes(filter: { name: $connectUrl }) { recordings { active { data { name downloadUrl reportUrl metadata { labels } } } archived { data { name downloadUrl reportUrl metadata { labels } size } } } } }",
"variables": {
"connectUrl": "service:jmx:rmi:///jndi/rmi://carbon:9091/jmxrmi"
}
}
```

Since both subviews normally update themselves dynamically using WebSockets, it should be reasonable to supply them both with an initial state populated by this single query and then allow them to dynamically update on notifications afterward.

This would lead to some awkward code where auto-refresh would either need to be hoisted up to the parent component and cause a re-render of the child entirely on each update, or else the auto-refresh would still be performed by each subview using separate queries. This could be removed after https://github.com/cryostatio/cryostat-web/issues/619 is complete.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the Recordings view and its Active and Archived subviews, then trace the separate recordings and archivedRecordings requests shown in the issue. Review issue 619 before deciding how auto-refresh should be coordinated. Done means both subviews receive their initial state from one RecordingsForTarget GraphQL request while continuing to update from WebSocket notifications.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, react, typescript
Domain
api, frontend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.