Stop logging GraphQL type conflict deprecation warnings

What does this MR do and why?

Problem this MR solves

GraphQL-Ruby logs a three-line deprecation warning whenever a query selects one response key with two different types, which the GraphQL specification forbids. 26 of GitLab's own frontend queries do this, so instance logs fill with annoying warnings. One customer reported 102 entries in 15 minutes.

How this MR solves the problem

GitlabSchema now sets allow_legacy_invalid_return_type_conflicts to true and implements the hook GraphQL-Ruby calls for each conflict. The hook returns nil, so queries keep running exactly as before and no client sees a change. The log line does not appear anymore, instead the gitlab_graphql_return_type_conflicts_total Prometheus counter (labelled with the conflicting types and the operation name) is increased so we keep having visibility on the offenders.

Additionally, a guard in spec/graphql/all_queries_spec.rb turns these conflicts into validation errors and fails on any query outside a 26-entry known list, so the number of offending queries cannot grow.

Not in scope

Fixing those 26 queries needs the owning feature teams and is tracked on the issue.

References

Resolves: #586994 (closed)

Screenshots or screen recordings

How to set up and validate locally

The first block reproduces the current behaviour, the second is what this MR ships:

bundle exec rails runner '
d = Gitlab::Graphql::Queries.find(Rails.root.join("app/assets/javascripts/work_items/graphql/work_item_by_id.query.graphql")).first
GitlabSchema.default_logger Logger.new($stdout)

GitlabSchema.allow_legacy_invalid_return_type_conflicts nil
GitlabSchema.validate(d.text)   # logs 3 warning lines

GitlabSchema.allow_legacy_invalid_return_type_conflicts true
GitlabSchema.validate(d.text)   # silent
'

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Alberto Bignotti

Merge request reports

Loading
Loading