add create sell and buy crypto order mutations
This commit is contained in:
22
app/graphql/types/buy_crypto_order_type.rb
Normal file
22
app/graphql/types/buy_crypto_order_type.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class BuyCryptoOrderType < Types::BaseObject
|
||||
implements GraphQL::Types::Relay::Node
|
||||
global_id_field :id
|
||||
|
||||
graphql_name "BuyCryptoOrder"
|
||||
|
||||
field :id, ID, null: false
|
||||
|
||||
field :currency, CurrencyType, null: false
|
||||
def currency
|
||||
dataloader.with(Dataloader::Source, Currency).load(object.currency_id)
|
||||
end
|
||||
|
||||
field :status, ProcessStatusEnum, null: false
|
||||
field :paid_amount_cents, Integer, null: false
|
||||
field :received_amount, String, null: true
|
||||
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
|
||||
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
|
||||
end
|
||||
end
|
||||
@@ -9,7 +9,5 @@ module Types
|
||||
field :id, ID, null: false
|
||||
field :amount_cents, Integer, null: false
|
||||
field :amount_currency, String, null: false
|
||||
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
|
||||
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class MutationType < Types::BaseObject
|
||||
field :create_sell_crypto_order, mutation: Mutations::CreateSellCryptoOrder
|
||||
field :create_buy_crypto_order, mutation: Mutations::CreateBuyCryptoOrder
|
||||
end
|
||||
end
|
||||
|
||||
10
app/graphql/types/process_status_enum.rb
Normal file
10
app/graphql/types/process_status_enum.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class ProcessStatusEnum < Types::BaseEnum
|
||||
graphql_name "ProcessStatus"
|
||||
|
||||
value "PROCESSING", value: "processing"
|
||||
value "COMPLETED", value: "completed"
|
||||
value "CANCELED", value: "canceled"
|
||||
end
|
||||
end
|
||||
@@ -18,5 +18,15 @@ module Types
|
||||
def fiat_balances
|
||||
Pundit.policy_scope(current_user, FiatBalance)
|
||||
end
|
||||
|
||||
field :sell_crypto_orders, SellCryptoOrderType.connection_type, null: false
|
||||
def sell_crypto_orders
|
||||
[]
|
||||
end
|
||||
|
||||
field :buy_crypto_orders, BuyCryptoOrderType.connection_type, null: false
|
||||
def buy_crypto_orders
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
11
app/graphql/types/record_invalid_type.rb
Normal file
11
app/graphql/types/record_invalid_type.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Types
|
||||
class RecordInvalidType < Types::BaseObject
|
||||
graphql_name "RecordInvalid"
|
||||
field :full_messages, [String], null: false
|
||||
field :field_name, String, null: true
|
||||
field :messages, [String], null: true
|
||||
field :path, [String], null: true
|
||||
end
|
||||
end
|
||||
22
app/graphql/types/sell_crypto_order_type.rb
Normal file
22
app/graphql/types/sell_crypto_order_type.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
module Types
|
||||
class SellCryptoOrderType < Types::BaseObject
|
||||
implements GraphQL::Types::Relay::Node
|
||||
global_id_field :id
|
||||
|
||||
graphql_name "SellCryptoOrder"
|
||||
|
||||
field :id, ID, null: false
|
||||
|
||||
field :currency, CurrencyType, null: false
|
||||
def currency
|
||||
dataloader.with(Dataloader::Source, Currency).load(object.currency_id)
|
||||
end
|
||||
|
||||
field :status, ProcessStatusEnum, null: false
|
||||
field :paid_amount, String, null: false
|
||||
field :received_amount_cents, Integer, null: true
|
||||
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
|
||||
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user