summaryrefslogtreecommitdiff
path: root/app/graphql/types/terraform/state_type.rb
blob: f25f3a7789b9550cf1e99e68ed4b0e37b84c326b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

module Types
  module Terraform
    class StateType < BaseObject
      graphql_name 'TerraformState'

      authorize :read_terraform_state

      field :id, GraphQL::ID_TYPE,
            null: false,
            description: 'ID of the Terraform state'

      field :name, GraphQL::STRING_TYPE,
            null: false,
            description: 'Name of the Terraform state'

      field :locked_by_user, Types::UserType,
            null: true,
            authorize: :read_user,
            description: 'The user currently holding a lock on the Terraform state',
            resolve: -> (state, _, _) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, state.locked_by_user_id).find }

      field :locked_at, Types::TimeType,
            null: true,
            description: 'Timestamp the Terraform state was locked'

      field :created_at, Types::TimeType,
            null: false,
            description: 'Timestamp the Terraform state was created'

      field :updated_at, Types::TimeType,
            null: false,
            description: 'Timestamp the Terraform state was updated'
    end
  end
end