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/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 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