-
Notifications
You must be signed in to change notification settings - Fork 129
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
DEVPROD-3065: Update directive to handle SetLastRevision permission #7689
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.
Can we verify this in staging too?
@@ -136,6 +138,29 @@ func New(apiURL string) Config { | |||
} | |||
} | |||
|
|||
if operationContext == SetLastRevisionMutation { | |||
projectIdentifier, ok := args["opts"].(map[string]interface{})["projectIdentifier"].(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.
Can we just retrieve the project ID directly from the request or is that not possible?
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.
Could you show me which data structure you're referring to? "opts" refers to the mutation parameter where the directive was applied.
graphql/resolver.go
Outdated
opts := gimlet.PermissionOpts{ | ||
Resource: project.Id, | ||
ResourceType: evergreen.ProjectResourceType, | ||
Permission: evergreen.PermissionProjectSettings, | ||
RequiredLevel: evergreen.ProjectSettingsEdit.Value, |
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.
Since these opts are shared by CopyProjectMutation
, DeleteProjectMutation
and SetLastRevisionMutation
, I wonder if we can refactor a bit to make it less repetitive. I imagine CreateProjectMutation
might eventually belong in a different directive like how the legacy UI does it
Co-authored-by: minnakt <[email protected]>
I was able to test the changes in staging by executing the code-block within the SetLastRevision condition. |
graphql/resolver.go
Outdated
@@ -104,17 +106,21 @@ func New(apiURL string) Config { | |||
} | |||
} | |||
|
|||
generatePermissionOpts := func(projectId string) gimlet.PermissionOpts { |
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.
nit. maybe getPermissionOpts
would be a good name, i feel like generate implies something fancier
@@ -104,17 +106,21 @@ func New(apiURL string) Config { | |||
} | |||
} |
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.
(request) can we move the block for CreateProjectMutation
above the declaration of the args
variable, since it doesn't use the args
variable?
DEVPROD-3065
Description
SetLastRevision requires "edit project" permissions based on legacy code.
This mutation should always fail when dispatched from Spruce but it passes in during GQL integration tests and local EVG GQL playground. I think we discovered this before but I'm failing to find the ticket.