Class: Types::DesignManagement::DesignType

Inherits:
BaseObject
  • Object
show all
Defined in:
app/graphql/types/design_management/design_type.rb

Instance Method Summary collapse

Methods inherited from BaseObject

accepts, assignable?, authorization, authorize, authorized?, #current_user, #id

Methods included from Gitlab::Graphql::Present

#present, #unpresented

Instance Method Details

#cached_stateful_version(parent_node) ⇒ Object

Returns a ‘DesignManagement::Version` for this query based on the `atVersion` argument passed to a parent node if present, or otherwise the most recent `Version` for the issue.



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/graphql/types/design_management/design_type.rb', line 38

def cached_stateful_version(parent_node)
  version_gid = context[:at_version_argument] # See: DesignsResolver

  # Caching is scoped to an `issue_id` to allow us to cache the
  # most recent `Version` for an issue
  Gitlab::SafeRequestStore.fetch([request_cache_base_key, 'stateful_version', object.issue_id, version_gid]) do
    if version_gid
      GitlabSchema.object_from_id(version_gid, expected_type: ::DesignManagement::Version)&.sync
    else
      object.issue.design_versions.most_recent
    end
  end
end

#request_cache_base_keyObject



52
53
54
# File 'app/graphql/types/design_management/design_type.rb', line 52

def request_cache_base_key
  self.class.name
end

#web_urlObject



56
57
58
# File 'app/graphql/types/design_management/design_type.rb', line 56

def web_url
  Gitlab::UrlBuilder.build(object)
end