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, authorization_scopes, 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.



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/graphql/types/design_management/design_type.rb', line 49

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

#nameObject



71
72
73
# File 'app/graphql/types/design_management/design_type.rb', line 71

def name
  object.filename
end

#request_cache_base_keyObject



63
64
65
# File 'app/graphql/types/design_management/design_type.rb', line 63

def request_cache_base_key
  self.class.name
end

#web_urlObject



67
68
69
# File 'app/graphql/types/design_management/design_type.rb', line 67

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