-
Notifications
You must be signed in to change notification settings - Fork 6
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
EAS-2497 : Collect possible GraphQL queries during lowering #56
base: main
Are you sure you want to change the base?
Conversation
let mut operations = vec![]; | ||
if let std::result::Result::Ok(doc) = parse_query::<&str>(s) { | ||
doc.definitions.into_iter().for_each(|operation| { | ||
if let Definition::Operation(op) = operation { |
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.
Don't forget to collect possible queries from fragments as well.
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.
fragment componentParts on CompassCatalogQueryApi{
searchTeams(input: $test) {
... on CompassSearchTeamsConnection{
nodes {
teamId
}
}
}
}
query compass_query($test:CompassSearchTeamsInput!) {
compass {
...componentParts
}
}
You mean something like this ?
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.
Yeah
doc.definitions.into_iter().for_each(|operation| { | ||
if let Definition::Operation(op) = operation { | ||
match op { | ||
OperationDefinition::Mutation(mutation) => { |
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.
You can also have plain selection sets as well that need to be parsed.
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.
Does AGG allow this ?
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.
Pretty sure it did last time I checked, there was just a warning in the UI.
.filter(|f| permissions_resolver.contains_key(f)) | ||
.map(|f| permissions_resolver.get(f).unwrap().to_owned()) |
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.
.filter(|f| permissions_resolver.contains_key(f)) | |
.map(|f| permissions_resolver.get(f).unwrap().to_owned()) | |
.filter_map(|f| permissions_resolver.get(f)) |
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 spent a little while looking at this and I initially tried to do the func mut, but the permissions_resolver.get(f) returns a &&str
when we need a &str
. AFAIK, there is no way to convert within the filter_map right?
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.
You can just add a Option::copied
call after the get
.
@@ -99,7 +103,69 @@ impl fmt::Display for Error { | |||
} | |||
} | |||
|
|||
impl std::error::Error for Error {} | |||
fn check_graphql_and_perms(val: &Value) -> Vec<&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.
What's the string being returned here? And does it need to be a string in the first place?
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.
This goes back to my internship, we decided on using string instead of enums for returning permissions.... I suppose we can swtich that. Let me know if we should.
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 main reason I'm going on this now, is because you have to hardcode the permissions anyway with the mapping, which means that the permissions are known at compile time.
Though if that's a stand in for deserializing an actual permission map where the permissions aren't static, then you can leave it as str, though make sure to add a comment.
No description provided.