-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node list GraphQL Api : add fields + Add GraphQL Api to fetch transactions list on type #51
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should avoid to use But you can create a function to parse stringified type to atomized type. This approach will enable a validation for the existing type and will sanitize the input. Those checks can be done in the resolver itself. |
||
end) | ||
end | ||
end | ||
|
||
subscription do | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should avoid to use
String.to_atom
as it may create a overflow of the atom list in the Erlang VM. It's a security issue, and a way to bring down nodes for attackers.But you can either create a function to parse stringified type to atomized type, or use
String.to_existing_atom