I think I'm probably missing things. But I cannot get them to work.
I have a named query:
const FUND_BY_ID_ALL_ATTRIBUTES_QUERY: &str = r#"{
query fundById($id: Int!) {
fund(id: $id) {
id,
fundName,
fundGoal,
}
}
}"#;
And then a test:
...
let result = warp::test::request()
.method("POST")
.body(
json!({
"query": FUND_BY_ID_ALL_ATTRIBUTES_QUERY,
"variables": {
"id": fund.id,
}
})
.to_string(),
)
.reply(&graphql_filter)
.await;
...
And I cannot make it work.
If force the query as:
const FUND_BY_ID_ALL_ATTRIBUTES_QUERY: &str = r#"{
fund(id: 42) {
id,
fundName,
fundGoal,
votingPowerInfo,
votingPowerThreshold,
rewardsInfo,
fundStartTime,
fundEndTime,
nextFundStartTime,
chainVotePlans {
id,
chainVoteplanId,
chainVoteStartTime,
chainVoteEndTime,
chainCommitteeEndTime,
chainVoteplanPayload,
chainVoteEncryptionKey,
fundId
},
}
}"#;
works like a charm.
This is the weir panic:
query had errors: [{"message":" --> 2:24\n |\n2 | query fundById($id: Int!) {鈵奬n | ^---\n |\n = expected name","locations":[{"line":2,"column":24}]}]
You have an extra brace, and the following is a valid GraphQL query.
query fundById($id: Int!) {
fund(id: $id) {
id,
fundName,
fundGoal,
},
}
@sunli829, sorry, the brace was a typo from reducing the example. Since the original query has more fields.
Named query is supported. There is only one possibility for this error. The query statement does not conform to the GraphQL specification.
I'll check it deeper. I may be missing something for sure. Thanks for the quick replay @sunli829 !! 馃槃