project_type.rb 3.1 KB
Newer Older
1 2
# frozen_string_literal: true

3 4
module Types
  class ProjectType < BaseObject
5 6
    expose_permissions Types::PermissionTypes::Project

7
    graphql_name 'Project'
N
Nick Thomas 已提交
8

9
    field :id, GraphQL::ID_TYPE, null: false
N
Nick Thomas 已提交
10

11 12
    field :full_path, GraphQL::ID_TYPE, null: false
    field :path, GraphQL::STRING_TYPE, null: false
N
Nick Thomas 已提交
13

14 15
    field :name_with_namespace, GraphQL::STRING_TYPE, null: false
    field :name, GraphQL::STRING_TYPE, null: false
N
Nick Thomas 已提交
16

17
    field :description, GraphQL::STRING_TYPE, null: true
N
Nick Thomas 已提交
18

19 20
    field :default_branch, GraphQL::STRING_TYPE, null: true
    field :tag_list, GraphQL::STRING_TYPE, null: true
N
Nick Thomas 已提交
21

22 23 24
    field :ssh_url_to_repo, GraphQL::STRING_TYPE, null: true
    field :http_url_to_repo, GraphQL::STRING_TYPE, null: true
    field :web_url, GraphQL::STRING_TYPE, null: true
N
Nick Thomas 已提交
25

26 27
    field :star_count, GraphQL::INT_TYPE, null: false
    field :forks_count, GraphQL::INT_TYPE, null: false
N
Nick Thomas 已提交
28

29 30
    field :created_at, Types::TimeType, null: true
    field :last_activity_at, Types::TimeType, null: true
N
Nick Thomas 已提交
31

32
    field :archived, GraphQL::BOOLEAN_TYPE, null: true
N
Nick Thomas 已提交
33

34
    field :visibility, GraphQL::STRING_TYPE, null: true
N
Nick Thomas 已提交
35

36 37 38 39
    field :container_registry_enabled, GraphQL::BOOLEAN_TYPE, null: true
    field :shared_runners_enabled, GraphQL::BOOLEAN_TYPE, null: true
    field :lfs_enabled, GraphQL::BOOLEAN_TYPE, null: true
    field :merge_requests_ff_only_enabled, GraphQL::BOOLEAN_TYPE, null: true
N
Nick Thomas 已提交
40

41 42 43
    field :avatar_url, GraphQL::STRING_TYPE, null: true, resolve: -> (project, args, ctx) do
      project.avatar_url(only_path: false)
    end
N
Nick Thomas 已提交
44

45 46 47 48
    %i[issues merge_requests wiki snippets].each do |feature|
      field "#{feature}_enabled", GraphQL::BOOLEAN_TYPE, null: true, resolve: -> (project, args, ctx) do
        project.feature_available?(feature, ctx[:current_user])
      end
N
Nick Thomas 已提交
49 50
    end

51 52 53
    field :jobs_enabled, GraphQL::BOOLEAN_TYPE, null: true, resolve: -> (project, args, ctx) do
      project.feature_available?(:builds, ctx[:current_user])
    end
N
Nick Thomas 已提交
54

55
    field :public_jobs, GraphQL::BOOLEAN_TYPE, method: :public_builds, null: true
N
Nick Thomas 已提交
56

57 58 59
    field :open_issues_count, GraphQL::INT_TYPE, null: true, resolve: -> (project, args, ctx) do
      project.open_issues_count if project.feature_available?(:issues, ctx[:current_user])
    end
N
Nick Thomas 已提交
60

61 62
    field :import_status, GraphQL::STRING_TYPE, null: true
    field :ci_config_path, GraphQL::STRING_TYPE, null: true
N
Nick Thomas 已提交
63

64 65 66 67
    field :only_allow_merge_if_pipeline_succeeds, GraphQL::BOOLEAN_TYPE, null: true
    field :request_access_enabled, GraphQL::BOOLEAN_TYPE, null: true
    field :only_allow_merge_if_all_discussions_are_resolved, GraphQL::BOOLEAN_TYPE, null: true
    field :printing_merge_request_link_enabled, GraphQL::BOOLEAN_TYPE, null: true
68 69 70 71 72 73 74

    field :merge_request,
          Types::MergeRequestType,
          null: true,
          resolver: Resolvers::MergeRequestResolver do
      authorize :read_merge_request
    end
B
Bob Van Landuyt 已提交
75

P
Phil Hughes 已提交
76 77 78 79 80
    field :issues,
          Types::IssueType.connection_type,
          null: true,
          resolver: Resolvers::IssuesResolver

B
Bob Van Landuyt 已提交
81 82 83 84
    field :pipelines,
          Types::Ci::PipelineType.connection_type,
          null: false,
          resolver: Resolvers::ProjectPipelinesResolver
85
  end
N
Nick Thomas 已提交
86
end