Class: HasHelpers::Resolvers::Cards::AvailableCards

Inherits:
GraphQL::Schema::Resolver
  • Object
show all
Defined in:
app/graphql/has_helpers/resolvers/cards/available_cards.rb

Overview

Resolves the catalog of cards available for a given resource WITHOUT record data. Global (not scoped to a role): returns card definitions plus their non-persisted icon hints. API:

availableCards(resourceName: String!): [Cards::AvailableCardType!]!

Instance Method Summary collapse

Instance Method Details

#resolve(resource_name:) ⇒ Object

Raises:

  • (GraphQL::ExecutionError)


16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/graphql/has_helpers/resolvers/cards/available_cards.rb', line 16

def resolve(resource_name:)
  app = context[:current_application]
  raise GraphQL::ExecutionError, "current_application missing from GraphQL context" if app.nil?

  resource = ::HasHelpers::Resource.find_by!(
    name: resource_name.to_s,
    application_id: app.id,
    parent_id: nil
  )

  ::HasHelpers::Cards::AvailableCardsCommand.call(resource_id: resource)
end