wallet screen
This commit is contained in:
13
app/graphql/types/balance_type.rb
Normal file
13
app/graphql/types/balance_type.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class BalanceType < Types::BaseObject
|
||||
implements GraphQL::Types::Relay::Node
|
||||
global_id_field :id
|
||||
|
||||
graphql_name "Balance"
|
||||
|
||||
field :id, ID, null: false
|
||||
field :currency, CurrencyType, null: false
|
||||
field :amount, String, null: false
|
||||
end
|
||||
end
|
||||
12
app/graphql/types/currency_type.rb
Normal file
12
app/graphql/types/currency_type.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class CurrencyType < Types::BaseObject
|
||||
implements GraphQL::Types::Relay::Node
|
||||
global_id_field :id
|
||||
|
||||
graphql_name "Currency"
|
||||
|
||||
field :id, ID, null: false
|
||||
field :name, String, null: false
|
||||
end
|
||||
end
|
||||
@@ -8,5 +8,10 @@ module Types
|
||||
def current_user
|
||||
context[:current_user]
|
||||
end
|
||||
|
||||
field :balances, BalanceType.connection_type, null: false
|
||||
def balances
|
||||
Pundit.policy_scope(current_user, Balance)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
module Types
|
||||
class UserType < Types::BaseObject
|
||||
# implements GraphQL::Types::Relay::Node
|
||||
|
||||
global_id_field :id
|
||||
|
||||
graphql_name "User"
|
||||
|
||||
field :id, ID, null: false
|
||||
field :first_name, String, null: false
|
||||
field :last_name, String, null: false
|
||||
|
||||
Reference in New Issue
Block a user