Sha256: de5454acf4aec74ec4da9979dc1a78e5946eeba232aaf8b9ff7294a2d8ce253a

Contents?: true

Size: 736 Bytes

Versions: 7

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

module Osso
  module GraphQL
    module Mutations
      class DeleteOauthClient < BaseMutation
        null false

        argument :id, ID, required: true

        field :oauth_client, Types::OauthClient, null: true
        field :errors, [String], null: false

        def resolve(id:)
          oauth_client = Osso::Models::OauthClient.find(id)

          return response_data(oauth_client: nil) if oauth_client.destroy

          response_error(errors: oauth_client.errors.full_messages)
        end

        def ready?(*)
          return true if context[:scope] == :admin

          raise ::GraphQL::ExecutionError, 'Only admin users may mutate OauthClients'
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
osso-0.0.3.16 lib/osso/graphql/mutations/delete_oauth_client.rb
osso-0.0.3.15 lib/osso/graphql/mutations/delete_oauth_client.rb
osso-0.0.3.14 lib/osso/graphql/mutations/delete_oauth_client.rb
osso-0.0.3.13 lib/osso/graphql/mutations/delete_oauth_client.rb
osso-0.0.3.12 lib/osso/graphql/mutations/delete_oauth_client.rb
osso-0.0.3.11 lib/osso/graphql/mutations/delete_oauth_client.rb
osso-0.0.3.9 lib/osso/graphql/mutations/delete_oauth_client.rb