From 189f37d361966f14bea05e896659abf14af24112 Mon Sep 17 00:00:00 2001 From: george-dorin <120329946+george-dorin@users.noreply.github.com> Date: Mon, 12 Jun 2023 13:38:34 +0300 Subject: [PATCH] Add node order resolver (#9554) --- core/web/resolver/node.go | 5 +++++ core/web/resolver/node_test.go | 7 ++++++- core/web/schema/type/node.graphql | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/web/resolver/node.go b/core/web/resolver/node.go index f411a6c06d1..df3910f4bb2 100644 --- a/core/web/resolver/node.go +++ b/core/web/resolver/node.go @@ -81,6 +81,11 @@ func (r *NodeResolver) SendOnly() bool { return orZero(r.node.SendOnly) } +// Order resolves the node's order field +func (r *NodeResolver) Order() *int32 { + return r.node.Order +} + // Chain resolves the node's chain object field. func (r *NodeResolver) Chain(ctx context.Context) (*ChainResolver, error) { chain, err := loader.GetChainByID(ctx, r.status.ChainID) diff --git a/core/web/resolver/node_test.go b/core/web/resolver/node_test.go index c5a3933b3f9..65c57848fdc 100644 --- a/core/web/resolver/node_test.go +++ b/core/web/resolver/node_test.go @@ -106,6 +106,7 @@ func Test_NodeQuery(t *testing.T) { name wsURL httpURL + order } ... on NotFoundError { message @@ -127,6 +128,7 @@ func Test_NodeQuery(t *testing.T) { Name: &name, WSURL: models.MustParseURL("ws://some-url"), HTTPURL: models.MustParseURL("http://some-url"), + Order: ptr(int32(11)), }}}) }, query: query, @@ -135,7 +137,8 @@ func Test_NodeQuery(t *testing.T) { "node": { "name": "node-name", "wsURL": "ws://some-url", - "httpURL": "http://some-url" + "httpURL": "http://some-url", + "order": 11 } }`, }, @@ -158,3 +161,5 @@ func Test_NodeQuery(t *testing.T) { RunGQLTests(t, testCases) } + +func ptr[T any](t T) *T { return &t } diff --git a/core/web/schema/type/node.graphql b/core/web/schema/type/node.graphql index 8ddcc1b21c8..67c2cada9b4 100644 --- a/core/web/schema/type/node.graphql +++ b/core/web/schema/type/node.graphql @@ -6,6 +6,7 @@ type Node { chain: Chain! state: String! sendOnly: Boolean! + order: Int } union NodePayload = Node | NotFoundError