Query declaration error for graphql createPackageProtectionRule
requested to merge gitlab-community/gitlab:416381-protected-packages-graphql-mutation-create-package-protection-rule-follow-up-fix-query-declaration-error into master
What does this MR do and why?
- Fixing the error that occurs when including
packageProtectionRule
in the query declaration of the graphql mutationcreatesPackageProtectionRule
- On master, there is currently a bug concerning the (recently added) grapqhl mutation
createPackagesProtectionRule
. When executing the graphql mutationcreatePackagesProtectionRule
and adding thepackageProtectionRule
in the query declaration, then we receive an internal server error, see below - Adding policy for
Packages::Protection::Rule
necessary to fix the bug and the new test cases; this missing policy was not needed because the existing test cases did not cover this execution path - This MR is a follow-up of the MR Protected packages: GraphQL api for creating pa... (!125915 - merged)
Screenshots or screen recordings
As explained in the description, this MR allows to declare the query packageProtectionRule
in the graphql mutation without getting any errors. The body of the graphql request looks like this:
mutation {
createPackagesProtectionRule(
input: {
projectPath: "flightjs/Flight"
packageNamePattern: "@flight/flight-10*"
packageType: NPM
pushProtectedUpToAccessLevel: MAINTAINER
}
) {
packageProtectionRule {
packageNamePattern
packageType
pushProtectedUpToAccessLevel
}
errors
}
}
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Enable feature flag via
rails c
Feature.enable(:packages_protected_packages)
- Now, you should be able to send mutation requests with the query declaration
packageProtectionRule
via the graphql api <= this would have crashed on the branchmaster
🐛
curl --request POST \
--url http://gdk.test:3000/api/graphql \
--header 'Authorization: Bearer ypCa3Dzb23o5nvsixwPA' \
--header 'Content-Type: application/json' \
--cookie 'perf_bar_enabled=true; BetterErrors-2.10.1-CSRF-Token=0b882179-5e4a-431b-a420-2be3701cece8' \
--data '{"query":"mutation {\n\tcreatePackagesProtectionRule(\n\t\tinput: {\n\t\t\tprojectPath: \"flightjs/Flight\"\n\t\t\tpackageNamePattern: \"@flight/flight-10*\"\n\t\t\tpackageType: NPM\n\t\t\tpushProtectedUpToAccessLevel: MAINTAINER\n\t\t}\n\t) {\n\t\tpackageProtectionRule {\n\t\t\tpackageNamePattern\n\t\t\tpackageType\n\t\t\tpushProtectedUpToAccessLevel\n\t\t}\n\t\terrors\n\t}\n}\n"}'
Todos
-
Exlcude the id form this MR
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR. -
Changelog entry added, if necessary -
Documentation created/updated via this MR -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Tested in all supported browsers -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the javascript style guides -
Conforms to the database guides
-
Related to #416381 (closed)
Edited by Gerardo Navarro