Sha256: 822fa4b221eba068c043db1424cd57f6204e6ab04d01726d39384037fabdd6f4

Contents?: true

Size: 753 Bytes

Versions: 7

Compression:

Stored size: 753 Bytes

Contents

# frozen_string_literal: true

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

        argument :name, String, required: true

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

        def resolve(**args)
          oauth_client = Osso::Models::OauthClient.new(args)

          return response_data(oauth_client: oauth_client) if oauth_client.save

          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/create_oauth_client.rb
osso-0.0.3.15 lib/osso/graphql/mutations/create_oauth_client.rb
osso-0.0.3.14 lib/osso/graphql/mutations/create_oauth_client.rb
osso-0.0.3.13 lib/osso/graphql/mutations/create_oauth_client.rb
osso-0.0.3.12 lib/osso/graphql/mutations/create_oauth_client.rb
osso-0.0.3.11 lib/osso/graphql/mutations/create_oauth_client.rb
osso-0.0.3.9 lib/osso/graphql/mutations/create_oauth_client.rb