Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce listing nodes requests #3468

Open
zaelgohary opened this issue Sep 25, 2024 · 0 comments
Open

Reduce listing nodes requests #3468

zaelgohary opened this issue Sep 25, 2024 · 0 comments
Labels
Milestone

Comments

@zaelgohary
Copy link
Contributor

zaelgohary commented Sep 25, 2024

Which package/s are you suggesting this feature for?

Dashboard, grid_client

Is your feature request related to a problem? Please describe

Currently, we're making a request per node to get its twin ID via Graphql.

image

image

image

Describe the solution you'd like

Use nodeID_in to get all twins at once.

query getNodeTwinId {
  nodes(where: {nodeID_in: [10, 11, 12, 13]}) {
    twinID
    nodeID
  }
}

Issue is in

async getNodeTwinId(node_id: number): Promise<number> {
const body = `query getNodeTwinId($nodeId: Int!){
nodes(where: { nodeID_eq: $nodeId }) {
twinID
}
}`;
return this.gqlClient
.query(body, { nodeId: node_id })
.then(response => {
if (response["data"]["nodes"]["length"] === 0) {
throw new ValidationError(`Couldn't find a node with id: ${node_id}.`);
}
return response["data"]["nodes"][0]["twinID"];
})
.catch(e => {
(e as Error).message = formatErrorMessage(`Error getting node twin ID for ID ${node_id}`, e);
throw e;
});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants