Sha256: 56b726a44245cd284ba8f43f2158afcb7d828708bb7b7eec77a4743681c184a0

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

# :nocov:
module Sail
  module Graphql
    module Mutations # :nodoc:
      extend ActiveSupport::Concern

      included do
        field :sail_set, mutation: SailSet do
          description "Set the value for a setting."
          argument :name, String, required: true
          argument :value, String, required: true
        end

        field :sail_profile_switch, mutation: SailProfileSwitch do
          description "Switches to the chosen profile."
          argument :name, String, required: true
        end
      end

      class SailSet < ::GraphQL::Schema::Mutation # :nodoc:
        argument :name, String, required: true
        argument :value, String, required: true

        field :success, Boolean, null: false

        def resolve(name:, value:)
          _, success = Sail.set(name, value)
          { success: success }
        end
      end

      class SailProfileSwitch < ::GraphQL::Schema::Mutation # :nodoc:
        argument :name, String, required: true

        field :success, Boolean, null: false

        def resolve(name:)
          success = Profile.exists?(name: name)
          Profile.switch(name)

          { success: success }
        end
      end
    end
  end
end
# :nocov:

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sail-3.6.1 lib/sail/mutations.rb
sail-3.6.0 lib/sail/mutations.rb
sail-3.5.1 lib/sail/mutations.rb
sail-3.5.0 lib/sail/mutations.rb
sail-3.4.0 lib/sail/mutations.rb
sail-3.3.0 lib/sail/mutations.rb