Class: Types::WorkItemIdType
Overview
rubocop:disable Graphql/AuthorizeTypes TODO: This type should be removed when Work Items become generally available. This mechanism is introduced temporarily to make the client implementation easier during this transition.
Class Method Summary
collapse
[], model_name_to_graphql_name
Class Method Details
28
29
30
31
32
33
34
35
|
# File 'app/graphql/types/work_item_id_type.rb', line 28
def coerce_input(string, ctx)
gid = super
return if gid.nil?
return work_item_gid(gid) if suitable?(gid)
raise GraphQL::CoercionError, "#{string.inspect} does not represent an instance of WorkItem"
end
|
.coerce_result(gid, ctx) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'app/graphql/types/work_item_id_type.rb', line 19
def coerce_result(gid, ctx)
global_id = ::Gitlab::GlobalId.as_global_id(gid, model_name: 'WorkItem')
raise GraphQL::CoercionError, "Expected a WorkItem ID, got #{global_id}" unless suitable?(global_id)
work_item_gid(global_id).to_s
end
|
.suitable?(gid) ⇒ Boolean
37
38
39
40
41
42
43
44
45
|
# File 'app/graphql/types/work_item_id_type.rb', line 37
def suitable?(gid)
return false if gid&.model_name&.safe_constantize.blank?
[::WorkItem, ::Issue].any? { |model_class| gid.model_class == model_class }
end
|