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.


31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/graphql/types/design_management/design_type.rb', line 31

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


45
46
47
# File 'app/graphql/types/design_management/design_type.rb', line 45

def request_cache_base_key
  self.class.name
end

#web_urlObject


49
50
51
# File 'app/graphql/types/design_management/design_type.rb', line 49

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