Skip to content

GraphQL triggers: use symbols not strings

Matthias Käppler requested to merge mk-gql-triggers-symbols into master

What does this MR do and why?

GraphQL subscriptions are defined as fields on the SubscriptionType. The first argument is the name of the event to be triggered. We use Ruby symbols to define this, e.g.:

    field :issuable_assignees_updated,
      subscription: Subscriptions::IssuableUpdated, null: true,
      description: 'Triggered when the assignees of an issuable are updated.'

However, when actually triggering this event we are using camel-case strings instead of snake-case symbols:

::GitlabSchema.subscriptions.trigger('issuableAssigneesUpdated')

This is allowed, and is in fact what the frontend sends in the original GQL subscription query, but it's inconsistent with how they are referenced in Rails and honestly, quite confusing. The official docs also suggest to use symbols for triggers "which corresponds to the field on subscription type": https://graphql-ruby.org/subscriptions/triggers.html

Let's change this so that we use symbols everywhere to reference trigger names in the backend.

This is a refactor and has no user-facing impact.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports