Sha256: 05d976a825af9a4aa0786e82056e979edea0e425e4a8d0c591bf808b4078fbdf

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

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

        argument :enterprise_account_id, ID, required: true
        argument :service, Types::IdentityProviderService, required: false

        field :identity_provider, Types::IdentityProvider, null: false
        field :errors, [String], null: false

        def resolve(service: nil, **args)
          customer = enterprise_account(**args)

          identity_provider = customer.identity_providers.build(
            service: service,
            domain: customer.domain,
            oauth_client_id: customer.oauth_client_id,
          )

          return response_data(identity_provider: identity_provider) if identity_provider.save

          response_error(errors: identity_provider.errors.full_messages)
        end

        def domain(**args)
          enterprise_account(**args)&.domain
        end

        def enterprise_account(enterprise_account_id:, **_args)
          @enterprise_account ||= Osso::Models::EnterpriseAccount.find(enterprise_account_id)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
osso-0.0.3.26 lib/osso/graphql/mutations/create_identity_provider.rb
osso-0.0.3.25 lib/osso/graphql/mutations/create_identity_provider.rb
osso-0.0.3.24 lib/osso/graphql/mutations/create_identity_provider.rb
osso-0.0.3.23 lib/osso/graphql/mutations/create_identity_provider.rb
osso-0.0.3.22 lib/osso/graphql/mutations/create_identity_provider.rb
osso-0.0.3.21 lib/osso/graphql/mutations/create_identity_provider.rb
osso-0.0.3.20 lib/osso/graphql/mutations/create_identity_provider.rb
osso-0.0.3.19 lib/osso/graphql/mutations/create_identity_provider.rb
osso-0.0.3.18 lib/osso/graphql/mutations/create_identity_provider.rb
osso-0.0.3.17 lib/osso/graphql/mutations/create_identity_provider.rb