Skip to content

Commit

Permalink
feat: Helper function for a gql network query
Browse files Browse the repository at this point in the history
Signed-off-by: Anirudh <[email protected]>
  • Loading branch information
anirudh2 committed Mar 8, 2023
1 parent 6d70a4e commit 609320b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,32 @@ function aquery()
f = ["allocatedTokens", "subgraphDeployment{ipfsHash}", "indexer{id}"]
return v, a, f
end

"""
nquery()
Return the components of a GraphQL query for network parameters.
For use with the TheGraphData.jl package.
```julia
julia> using AllocationOpt
julia> value, args, fields = AllocationOpt.nquery()
```
# Extended Help
You can find TheGraphData.jl at https://github.com/semiotic-ai/TheGraphData.jl
"""
function nquery()
v = "graphNetwork"
a = Dict("id" => 1)
f = [
"id",
"totalSupply",
"networkGRTIssuance",
"epochLength",
"totalTokensSignalled",
"currentEpoch",
]
return v, a, f
end
14 changes: 14 additions & 0 deletions test/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,18 @@
"where" => Dict("status" => "Active")
)
end

@testset "nquery" begin
v, a, f = AllocationOpt.nquery()
@test v == "graphNetwork"
@test f == [
"id",
"totalSupply",
"networkGRTIssuance",
"epochLength",
"totalTokensSignalled",
"currentEpoch",
]
@test a == Dict("id" => 1)
end
end

0 comments on commit 609320b

Please sign in to comment.