-
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
Add support for classifying Compass API calls from @forge/graphql package with tests and testing parameters bug fix #66
Conversation
Looks good so far. Just need to map public api methods from that package to scopes |
cd1d654
to
857f954
Compare
a86bb3c
to
fddbb9f
Compare
} | ||
|
||
// This is for handling https://developer.atlassian.com/cloud/compass/forge-graphql-toolkit/ | ||
fn load_compass_api_scopes() -> HashMap<String, Vec<String>> { |
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.
fn load_compass_api_scopes() -> HashMap<String, Vec<String>> { | |
fn load_compass_api_scopes() -> HashMap<&'static str, Vec<&'static str>> { |
str
s created from include_str!
are static
, so you don't need to allocate new ones.
} | ||
|
||
/// Retrieves permissions for a given key. Prints a warning if the key is missing. | ||
pub fn get(&self, key: &str) -> Option<&Vec<String>> { |
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.
pub fn get(&self, key: &str) -> Option<&Vec<String>> { | |
pub fn get(&self, key: &str) -> Option<&[String]> { |
Generally speaking, it's usually better to return or accept slices instead of shared references to Vec
s, since you can't do anything more with a &Vec
besides reading the capacity of the buffer.
You can just change the signature of the function, and permissions
should auto deref to match the slice return type.
If you want to do it manually, you can get a slice from a reference to a Vec
by using Some(&**permissions)
or Some(&permissions[..])
.
// import graphqlGateway from "@atlassian/forge-graphql"; | ||
// const { errors, data} = await graphqlGateway.compass.asApp().getComponent({ componentId }); | ||
// [PropPath::Def(def), PropPath::Static(ref compass), ref auth | ||
[PropPath::Def(def), PropPath::Static(ref compass), ref authn @ .., PropPath::Static(ref function_name)] |
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.
Couldn't you just match for PropPath::MemberCall
directly here instead of using a slice pattern?
Add Compass asApp/asUser from default import: https://www.npmjs.com/package/@atlassian/forge-graphql