Class: Types::BaseObject

Inherits:
GraphQL::Schema::Object
  • Object
show all
Includes:
Gitlab::Graphql::ExposePermissions, Gitlab::Graphql::MarkdownField, Gitlab::Graphql::Present
Defined in:
app/graphql/types/base_object.rb

Direct Known Subclasses

AbuseReportType, AccessLevelType, AccessLevels::DeployKeyType, AccessLevels::UserType, Achievements::AchievementType, Achievements::UserAchievementType, Admin::Analytics::UsageTrends::MeasurementType, Admin::SidekiqQueues::DeleteJobsResponseType, AlertManagement::AlertStatusCountsType, AlertManagement::AlertType, AlertManagement::HttpIntegrationType, AlertManagement::PrometheusIntegrationType, Analytics::CycleAnalytics::LinkType, Analytics::CycleAnalytics::MetricType, AuditEvents::DefinitionType, AwardEmojis::AwardEmojiType, Types::Blame::BlameType, Types::Blame::CommitDataType, Types::Blame::GroupsType, BlobViewerType, BoardListType, BoardType, Types::BranchProtections::BaseAccessLevelType, Types::BranchRules::BranchProtectionType, BranchType, Ci::AnalyticsType, Ci::ApplicationSettingType, Ci::BuildNeedType, Ci::CiCdSettingType, Ci::CodeQualityReportSummaryType, Ci::Config::ConfigType, Ci::Config::GroupType, Ci::Config::IncludeType, Ci::Config::JobRestrictionType, Ci::Config::JobType, Ci::Config::NeedType, Ci::Config::StageType, Ci::ConfigVariableType, Ci::DetailedStatusType, Ci::FreezePeriodType, Ci::GroupEnvironmentScopeType, Ci::GroupType, Ci::GroupVariableType, Ci::InheritedCiVariableType, Ci::InstanceVariableType, Ci::JobArtifactType, Ci::JobTokenScopeType, Ci::JobTraceType, Ci::JobType, Ci::ManualVariableType, Ci::PipelineCountsType, Ci::PipelineMessageType, Ci::PipelineScheduleType, Ci::PipelineScheduleVariableType, Ci::PipelineTriggerType, Ci::PipelineType, Ci::ProjectVariableType, Ci::RecentFailuresType, Ci::RunnerArchitectureType, Ci::RunnerManagerType, Ci::RunnerPlatformType, Ci::RunnerSetupType, Ci::RunnerType, Ci::StageType, Ci::StatusActionType, Ci::TemplateType, Ci::TestCaseType, Ci::TestReportSummaryType, Ci::TestReportTotalType, Ci::TestSuiteSummaryType, Ci::TestSuiteType, CiConfiguration::Sast::AnalyzersEntityType, CiConfiguration::Sast::EntityType, CiConfiguration::Sast::OptionsEntityType, CiConfiguration::Sast::Type, Clusters::AgentActivityEventType, Clusters::AgentTokenType, Clusters::AgentType, Clusters::Agents::Authorizations::CiAccessType, Clusters::Agents::Authorizations::UserAccessType, CommitReferencesType, CommitSignatures::GpgSignatureType, CommitSignatures::SshSignatureType, CommitSignatures::X509SignatureType, CommitType, ContainerExpirationPolicyType, ContainerRepositoryTagType, ContainerRepositoryType, CustomEmojiType, CustomerRelations::ContactStateCountsType, CustomerRelations::ContactType, CustomerRelations::OrganizationStateCountsType, CustomerRelations::OrganizationType, DataTransfer::BaseType, DataTransfer::EgressNodeType, DeploymentTagType, DeploymentType, DescriptionVersionType, DesignManagement::DesignAtVersionType, DesignManagement::DesignCollectionType, DesignManagement::DesignType, DesignManagement::VersionType, DesignManagementType, DiffRefsType, DiffStatsSummaryType, DiffStatsType, DiffType, EnvironmentType, ErrorTracking::SentryDetailedErrorType, ErrorTracking::SentryErrorCollectionType, ErrorTracking::SentryErrorFrequencyType, ErrorTracking::SentryErrorStackTraceContextType, ErrorTracking::SentryErrorStackTraceEntryType, ErrorTracking::SentryErrorStackTraceType, ErrorTracking::SentryErrorTagsType, ErrorTracking::SentryErrorType, EventType, EvidenceType, GrafanaIntegrationType, GroupInvitationType, GroupMemberType, IdeType, IncidentManagement::TimelineEventTagType, IncidentManagement::TimelineEventType, IssueStatusCountsType, IssueType, JiraImportType, JiraUserType, Kas::AgentConfigurationType, Kas::AgentConnectionType, Kas::AgentMetadataType, KeyType, LabelType, MergeRequestType, Metadata::KasType, MetadataType, Metrics::Dashboards::AnnotationType, MilestoneStatsType, MilestoneType, MutationType, NamespaceType, NestedEnvironmentType, Notes::DeletedNoteType, Notes::DiffPositionType, Notes::DiscussionType, Notes::NoteType, Notes::SystemNoteMetadataType, Organizations::OrganizationType, Organizations::OrganizationUserType, Packages::Cleanup::PolicyType, Packages::Composer::JsonType, Packages::Composer::MetadatumType, Packages::Conan::FileMetadatumType, Packages::Conan::MetadatumType, Packages::Helm::DependencyType, Packages::Helm::FileMetadatumType, Packages::Helm::MaintainerType, Packages::Helm::MetadataType, Packages::Maven::MetadatumType, Packages::Nuget::DependencyLinkMetadatumType, Packages::Nuget::MetadatumType, Packages::PackageBaseType, Packages::PackageDependencyLinkType, Packages::PackageDependencyType, Packages::PackageFileType, Packages::PackageLinksType, Packages::PackageTagType, Packages::Pypi::MetadatumType, PermissionTypes::BasePermissionType, ProjectInvitationType, ProjectMemberType, ProjectStatisticsRedirectType, ProjectStatisticsType, ProjectType, Projects::BranchRuleType, Projects::CommitParentNamesType, Projects::ForkDetailsType, Projects::RepositoryLanguageType, Projects::Services::BaseServiceType, Projects::Services::JiraProjectType, Projects::Services::JiraServiceType, Projects::TopicType, PrometheusAlertType, QueryComplexityType, QueryType, ReleaseAssetLinkType, ReleaseAssetsType, ReleaseLinksType, ReleaseSourceType, ReleaseType, Repository::BlobType, RepositoryType, RootStorageStatisticsType, SavedReplyType, Security::CodequalityReportsComparer::DegradationType, Security::CodequalityReportsComparer::ReportType, Security::CodequalityReportsComparer::SummaryType, Security::CodequalityReportsComparerType, SnippetType, Snippets::BlobType, SubscriptionType, TaskCompletionStatus, Terraform::StateType, Terraform::StateVersionType, TimeTracking::TimelogCategoryType, TimelogType, TodoType, Tree::BlobType, Tree::SubmoduleType, Tree::TreeEntryType, Tree::TreeType, UploadType, UserCalloutType, UserMergeRequestInteractionType, UserPreferencesType, UserStatusType, UserType, Users::EmailType, Users::NamespaceCommitEmailType, WorkItemType, WorkItems::LinkedItemType, WorkItems::TypeType, WorkItems::Widgets::AssigneesType, WorkItems::Widgets::AwardEmojiType, WorkItems::Widgets::CurrentUserTodosType, WorkItems::Widgets::DescriptionType, WorkItems::Widgets::HierarchyType, WorkItems::Widgets::LabelsType, WorkItems::Widgets::LinkedItemsType, WorkItems::Widgets::MilestoneType, WorkItems::Widgets::NotesType, WorkItems::Widgets::NotificationsType, WorkItems::Widgets::StartAndDueDateType, X509CertificateType, X509IssuerType

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Graphql::Present

#present, #unpresented

Class Method Details

.accepts(*types) ⇒ Object



19
20
21
22
23
# File 'app/graphql/types/base_object.rb', line 19

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

.assignable?(object) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
48
# File 'app/graphql/types/base_object.rb', line 42

def self.assignable?(object)
  assignable = accepts

  return true if assignable.blank?

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

.authorizationObject



30
31
32
# File 'app/graphql/types/base_object.rb', line 30

def self.authorization
  @authorization ||= ::Gitlab::Graphql::Authorize::ObjectAuthorization.new(authorize)
end

.authorize(*args) ⇒ Object



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

def self.authorize(*args)
  raise 'Cannot redefine authorize' if @authorize_args && args.any?

  @authorize_args = args.freeze if args.any?
  @authorize_args || (superclass.respond_to?(:authorize) ? superclass.authorize : nil)
end

.authorized?(object, context) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/graphql/types/base_object.rb', line 34

def self.authorized?(object, context)
  authorization.ok?(object, context[:current_user])
end

Instance Method Details

#current_userObject



38
39
40
# File 'app/graphql/types/base_object.rb', line 38

def current_user
  context[:current_user]
end

#idObject

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



26
27
28
# File 'app/graphql/types/base_object.rb', line 26

def id
  GitlabSchema.id_from_object(object)
end