Skip to content

Commit

Permalink
Add node order resolver (smartcontractkit#9554)
Browse files Browse the repository at this point in the history
  • Loading branch information
george-dorin authored Jun 12, 2023
1 parent 561cc89 commit 189f37d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions core/web/resolver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion core/web/resolver/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func Test_NodeQuery(t *testing.T) {
name
wsURL
httpURL
order
}
... on NotFoundError {
message
Expand All @@ -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,
Expand All @@ -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
}
}`,
},
Expand All @@ -158,3 +161,5 @@ func Test_NodeQuery(t *testing.T) {

RunGQLTests(t, testCases)
}

func ptr[T any](t T) *T { return &t }
1 change: 1 addition & 0 deletions core/web/schema/type/node.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type Node {
chain: Chain!
state: String!
sendOnly: Boolean!
order: Int
}

union NodePayload = Node | NotFoundError
Expand Down

0 comments on commit 189f37d

Please sign in to comment.