Leverage input types in DAST GraphQL queries
Over the last few months, we've introduced several DAST-related GraphQL mutations. Up until now, we've always written their input
explicitly in the client-side .graphql
files. This could be improved by leveraging input types defined in doc/api/graphql/reference/gitlab_schema.graphql
.
For example, dast_site_profile_create.mutation.graphql
could be cleaned up with a couple changes:
diff --git a/ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/components/dast_site_profile_form.vue b/ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/components/dast_site_profile_form.vue
index 0450c96ab6d..1587423f08f 100644
--- a/ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/components/dast_site_profile_form.vue
+++ b/ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/components/dast_site_profile_form.vue
@@ -105,9 +105,11 @@ export default {
const { errorMessage } = this.i18n;
const variables = {
- fullPath: this.fullPath,
- ...(this.isEdit ? { id: this.siteProfile.id } : {}),
- ...serializeFormObject(this.form.fields),
+ input: {
+ fullPath: this.fullPath,
+ ...(this.isEdit ? { id: this.siteProfile.id } : {}),
+ ...serializeFormObject(this.form.fields),
+ }
};
this.$apollo
diff --git a/ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/graphql/dast_site_profile_create.mutation.graphql b/ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/graphql/dast_site_profile_create.mutation.graphql
index bb7d7f030b4..a49b0daa64f 100644
--- a/ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/graphql/dast_site_profile_create.mutation.graphql
+++ b/ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/graphql/dast_site_profile_create.mutation.graphql
@@ -1,7 +1,5 @@
-mutation dastSiteProfileCreate($fullPath: ID!, $profileName: String!, $targetUrl: String) {
- dastSiteProfileCreate(
- input: { fullPath: $fullPath, profileName: $profileName, targetUrl: $targetUrl }
- ) {
+mutation dastSiteProfileCreate($input: DastSiteProfileCreateInput!) {
+ dastSiteProfileCreate(input: $input) {
id
errors
}
Let's review our current mutations and replace their individual payload parameters by a single input type when possible.
-
dastOnDemandScanCreate
:DastOnDemandScanCreateInput
-
dastScannerProfileDelete
:DastScannerProfileDeleteInput
-
dastSiteProfileDelete
:DastSiteProfileDeleteInput
-
dastScannerProfileCreate
:DastScannerProfileCreateInput
-
dastScannerProfileUpdate
:DastScannerProfileUpdateInput
-
dastSiteProfileCreate
:DastSiteProfileCreateInput
-
dastSiteProfileUpdate
:DastSiteProfileUpdateInput
Edited by Paul Gascou-Vaillancourt