-
Notifications
You must be signed in to change notification settings - Fork 987
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
Add graphman unassign/reassign commands to graphman graphql api #5678
base: master
Are you sure you want to change the base?
Add graphman unassign/reassign commands to graphman graphql api #5678
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good, but there are a few things to consider before I can complete my review:
- I would suggest rethinking the approach with warnings, so that we are not hiding potentially important details from users. It might be a good idea to break the commands into smaller pieces to allow more flexibility in the interfaces that assemble the commands (it is important not to allow assembling wrong commands);
- When I introduced the GraphQL API, we agreed that all implemented commands should have tests, and there are no tests for the new GraphQL commands;
- The primary use case for extracting the Graphman commands into a separate crate and breaking them into smaller pieces was to share the functionality between the CLI and the GraphQL API, but this PR does not share the extracted code with the CLI;
None => catalog_conn | ||
.assign_subgraph(&deployment.site, &node) | ||
.map_err(GraphmanError::from)?, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are hiding a potentially important detail about what actually happens.
I'm not sure what the best way to do this would be. One way would be to split the command into more pieces, so that when the API / CLI assembles the command, it decides how to proceed and what messages to generate. Another way would be to return some warnings in this function, but they are not very flexible and useful at this level.
let mirror = catalog::Mirror::primary_only(ctx.primary_pool); | ||
let count = mirror.assignments(&node)?.len(); | ||
if count == 1 { | ||
Ok(Response::new(true,format!("warning: this is the only deployment assigned to '{}'. Are you sure it is spelled correctly?",node.as_str()))) | ||
} else { | ||
Ok(Response::new( | ||
true, | ||
format!("Ressigned {} to {}", deployment.as_str(), node.as_str()), | ||
)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this belongs here, because this functionality is also used in the CLI, and it's not very nice to have it duplicated.
…into shiyasmohd/add-unassign-reassign-to-graphman-api
No description provided.