From c8c0d64a42f3abcce188797f05c67d9f769da5fb Mon Sep 17 00:00:00 2001 From: redDwarf03 Date: Sat, 7 Aug 2021 13:38:29 +0200 Subject: [PATCH 1/2] node list GraphQL Api : add fields --- lib/archethic_web/graphql_schema/p2p_type.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/archethic_web/graphql_schema/p2p_type.ex b/lib/archethic_web/graphql_schema/p2p_type.ex index 2690ea865..ce5719106 100644 --- a/lib/archethic_web/graphql_schema/p2p_type.ex +++ b/lib/archethic_web/graphql_schema/p2p_type.ex @@ -14,5 +14,7 @@ defmodule ArchEthicWeb.GraphQLSchema.P2PType do field(:geo_patch, :string) field(:network_patch, :string) field(:average_availability, :float) + field(:enrollment_date, :timestamp) + field(:authorization_date, :timestamp) end end From 1c9ab143f19bc0fe358d292a66087afbfce66837 Mon Sep 17 00:00:00 2001 From: redDwarf03 Date: Sat, 7 Aug 2021 13:39:34 +0200 Subject: [PATCH 2/2] Add GraphQL Api to fetch transactions list on type --- lib/archethic_web/graphql_schema.ex | 14 ++++++++++++++ lib/archethic_web/graphql_schema/resolver.ex | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/lib/archethic_web/graphql_schema.ex b/lib/archethic_web/graphql_schema.ex index 86f193021..bb760dcb7 100644 --- a/lib/archethic_web/graphql_schema.ex +++ b/lib/archethic_web/graphql_schema.ex @@ -97,6 +97,20 @@ defmodule ArchEthicWeb.GraphQLSchema do {:ok, Resolver.nodes()} end) end + + @desc """ + Query the network to list the transaction on the type + """ + field :network_transactions, list_of(:transaction) do + arg(:type, :string) + arg(:page, :integer) + + resolve(fn args, _ -> + type = Map.get(args, :type) + page = Map.get(args, :page, 1) + {:ok, Resolver.network_transactions(String.to_atom(type), page)} + end) + end end subscription do diff --git a/lib/archethic_web/graphql_schema/resolver.ex b/lib/archethic_web/graphql_schema/resolver.ex index d0bb7da04..06a50e7ad 100644 --- a/lib/archethic_web/graphql_schema/resolver.ex +++ b/lib/archethic_web/graphql_schema/resolver.ex @@ -98,4 +98,9 @@ defmodule ArchEthicWeb.GraphQLSchema.Resolver do } ) end + + def network_transactions(type, page) do + TransactionChain.list_transactions_by_type(type, []) + |> paginate_transactions(page) + end end