Class: Types::BaseObject

Inherits:
GraphQL::Schema::Object
  • Object
show all
Defined in:
app/graphql/types/base_object.rb

Direct Known Subclasses

AccessLevelType, Admin::Analytics::InstanceStatistics::MeasurementType, Admin::SidekiqQueues::DeleteJobsResponseType, AlertManagement::AlertStatusCountsType, AlertManagement::AlertType, AlertManagement::HttpIntegrationType, AlertManagement::PrometheusIntegrationType, AwardEmojis::AwardEmojiType, BoardListType, BoardType, BranchType, Ci::DetailedStatusType, Ci::GroupType, Ci::JobArtifactType, Ci::JobType, Ci::PipelineType, Ci::RunnerArchitectureType, Ci::RunnerPlatformType, Ci::RunnerSetupType, Ci::StageType, Ci::StatusActionType, CommitType, ContainerExpirationPolicyType, ContainerRepositoryTagType, ContainerRepositoryType, CustomEmojiType, DesignManagement::DesignAtVersionType, DesignManagement::DesignCollectionType, DesignManagement::DesignType, DesignManagement::VersionType, DesignManagementType, DiffRefsType, DiffStatsSummaryType, DiffStatsType, EnvironmentType, ErrorTracking::SentryDetailedErrorType, ErrorTracking::SentryErrorCollectionType, ErrorTracking::SentryErrorFrequencyType, ErrorTracking::SentryErrorStackTraceContextType, ErrorTracking::SentryErrorStackTraceEntryType, ErrorTracking::SentryErrorStackTraceType, ErrorTracking::SentryErrorTagsType, ErrorTracking::SentryErrorType, EvidenceType, GrafanaIntegrationType, GroupInvitationType, GroupMemberType, IssueStatusCountsType, IssueType, JiraImportType, JiraUserType, LabelType, MergeRequestType, MetadataType, Metrics::DashboardType, Metrics::Dashboards::AnnotationType, MilestoneStatsType, MilestoneType, MutationType, NamespaceType, Notes::DiffPositionType, Notes::DiscussionType, Notes::NoteType, PackageType, PermissionTypes::BasePermissionType, ProjectInvitationType, ProjectMemberType, ProjectStatisticsType, ProjectType, Projects::Services::BaseServiceType, Projects::Services::JiraProjectType, Projects::Services::JiraServiceType, PrometheusAlertType, QueryType, ReleaseAssetLinkType, ReleaseAssetsType, ReleaseLinksType, ReleaseSourceType, ReleaseType, RepositoryType, RootStorageStatisticsType, SnippetType, Snippets::BlobType, Snippets::BlobViewerType, TaskCompletionStatus, Terraform::StateType, Terraform::StateVersionType, TodoType, Tree::BlobType, Tree::SubmoduleType, Tree::TreeEntryType, Tree::TreeType, UserStatusType, UserType

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.accepts(*types) ⇒ Object


11
12
13
14
15
# File 'app/graphql/types/base_object.rb', line 11

def self.accepts(*types)
  @accepts ||= []
  @accepts += types
  @accepts
end

.assignable?(object) ⇒ Boolean

Returns:

  • (Boolean)

26
27
28
29
30
31
32
# File 'app/graphql/types/base_object.rb', line 26

def self.assignable?(object)
  assignable = accepts

  return true if assignable.blank?

  assignable.any? { |cls| object.is_a?(cls) }
end

Instance Method Details

#current_userObject


22
23
24
# File 'app/graphql/types/base_object.rb', line 22

def current_user
  context[:current_user]
end

#idObject

All graphql fields exposing an id, should expose a global id.


18
19
20
# File 'app/graphql/types/base_object.rb', line 18

def id
  GitlabSchema.id_from_object(object)
end