1 回答
TA贡献1998条经验 获得超6个赞
所以,我把 graphql 模式改成了:
var blockType = graphql.NewObject(
graphql.ObjectConfig{
Name: "block",
Fields: graphql.Fields{
"header" :&graphql.Field{
Type: headerType,
},
"payload": &graphql.Field{
Type: graphql.NewList(payloadType),
},
},
})
var payloadType = graphql.NewObject(
graphql.ObjectConfig{
Name: "payload",
Fields: graphql.Fields{
"from": &graphql.Field{
Type: graphql.String,
},
"to": &graphql.Field{
Type: graphql.String,
},
"value": &graphql.Field{
Type: graphql.Int,
},
"nonce": &graphql.Field{
Type: graphql.Int,
},
"data": &graphql.Field{
Type: graphql.String,
},
"time": &graphql.Field{
Type: graphql.Int,
},
"signature": &graphql.Field{
Type: graphql.String,
},
},
})
var headerType = graphql.NewObject(
graphql.ObjectConfig{
Name: "header",
Fields: graphql.Fields{
"parent": &graphql.Field{
Type: graphql.String,
},
"number": &graphql.Field{
Type: graphql.Int,
},
"nonce": &graphql.Field{
Type: graphql.Int,
},
"time": &graphql.Field{
Type: graphql.Int,
},
"miner": &graphql.Field{
Type: graphql.String,
},
},
},
)
现在,一切都按预期工作。看来这句话是罪魁祸首:
"payload": &graphql.Field{
Type: graphql.NewList(transactionType),
},
出于某种原因,如果你尝试做这种类型的嵌套go-graphql(或者graphql不知道该怎么做)。FWI:现在我的查询看起来像这样:
query{
blocks{header{parent,number,nonce,time,miner},payload{from,to,value,nonce,data,time,signature}}
}
并且它们会产生所需的结果。
- 1 回答
- 0 关注
- 100 浏览
添加回答
举报