Commit a33a602f authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'ajk-globalid-ignore-ee' into 'master'

Ajk globalid ignore EE

See merge request gitlab-org/gitlab!39478
parents a41449a1 3d4bd463
......@@ -48,6 +48,13 @@ class GitlabSchema < GraphQL::Schema
super(query_str, **kwargs)
end
def get_type(type_name)
# This is a backwards compatibility hack to work around an accidentally
# released argument typed as EEIterationID
type_name = type_name.gsub(/^EE/, '') if type_name.end_with?('ID')
super(type_name)
end
def id_from_object(object, _type = nil, _ctx = nil)
unless object.respond_to?(:to_global_id)
# This is an error in our schema and needs to be solved. So raise a
......@@ -144,6 +151,13 @@ class GitlabSchema < GraphQL::Schema
end
end
end
# This is a backwards compatibility hack to work around an accidentally
# released argument typed as EE{Type}ID
def get_type(type_name)
type_name = type_name.gsub(/^EE/, '') if type_name.end_with?('ID')
super(type_name)
end
end
GitlabSchema.prepend_if_ee('EE::GitlabSchema') # rubocop: disable Cop/InjectEnterpriseEditionModule
......
......@@ -4383,11 +4383,6 @@ type DismissVulnerabilityPayload {
vulnerability: Vulnerability
}
"""
Identifier of EE::Iteration
"""
scalar EEIterationID
interface Entry {
"""
Flat path of the entry
......@@ -7805,6 +7800,11 @@ type IterationEdge {
node: Iteration
}
"""
Identifier of Iteration
"""
scalar IterationID
"""
State of a GitLab iteration
"""
......@@ -12270,7 +12270,7 @@ type Query {
"""
Find an iteration by its ID
"""
id: EEIterationID!
id: IterationID!
): Iteration
"""
......
......@@ -12201,16 +12201,6 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "EEIterationID",
"description": "Identifier of EE::Iteration",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INTERFACE",
"name": "Entry",
......@@ -21532,6 +21522,16 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "IterationID",
"description": "Identifier of Iteration",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "IterationState",
......@@ -36095,7 +36095,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "EEIterationID",
"name": "IterationID",
"ofType": null
}
},
......@@ -10,7 +10,7 @@ module EE
null: true,
resolve: -> (_obj, args, _ctx) { ::GitlabSchema.find_by_gid(args[:id]) },
description: 'Find an iteration' do
argument :id, ::Types::GlobalIDType[Iteration],
argument :id, ::Types::GlobalIDType[::Iteration],
required: true,
description: 'Find an iteration by its ID'
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Types::GlobalIDType do
context 'where we declare an argument as GlobalIDType[a] where a is prepended in EE' do
def query(doc, vars)
GraphQL::Query.new(GitlabSchema.graphql_definition, document: doc, context: {}, variables: vars)
end
def run_query(gql_query, vars)
query(GraphQL.parse(gql_query), vars).result
end
let_it_be(:iteration) { create(:iteration) }
shared_examples 'a working query' do
it 'works' do
res = run_query(document, 'iterationId' => iteration.to_global_id.to_s)
expect(res['errors']).to be_blank
expect(res.dig('data', 'iteration')).to eq(
'iid' => iteration.iid.to_s,
'id' => iteration.to_global_id.to_s
)
end
end
context 'when the argument is declared by the client as IterationID' do
let(:document) do
<<-GRAPHQL
query($iterationId: IterationID!) {
iteration(id: $iterationId) {
id, iid
}
}
GRAPHQL
end
it_behaves_like 'a working query'
end
context 'when the argument is declared by the client as EEIterationID' do
let(:document) do
<<-GRAPHQL
query($iterationId: EEIterationID!) {
iteration(id: $iterationId) {
id, iid
}
}
GRAPHQL
end
it_behaves_like 'a working query'
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment