Sorry, I should have been more specific.
TLDR: Question is, when a query returns a collection are we expected to map it out of the response ourself?
Long Version:
I can make parameterized query requests, and I know they work, because if I change the return type of a query into String I can debug it and see that the request works.
For example:
Modified Debugging Schema:
type Query{
books(id: Int!): String
}
Resolver:
<query-request>
<sql-statement>select * from c where c.author_id = @code</sql-statement>
<parameters>
<parameter name="@code">@(context.GraphQL.Arguments["id"].ToString())</parameter>
</parameters>
</query-request>
Query:
query {
books(id: 1)
}
Response:
{
"data": {
"books": "{\"_rid\":\"RpMIAKjTVEQ=\",\"items\":[{\"id\":\"1\",\"title\":\"THe Light Fantastic\",\"genre\":\"Comedy\",\"author_id\":\"1\",\"_rid\":\"RpMIAKjTVEQBAAAAAAAAAA==\",\"_self\":\"dbs\\/RpMIAA==\\/colls\\/RpMIAKjTVEQ=\\/docs\\/RpMIAKjTVEQBAAAAAAAAAA==\\/\",\"_etag\":\"\\\"0400d01b-0000-1a00-0000-649262e90000\\\"\",\"_attachments\":\"attachments\\/\",\"_ts\":1687315177}],\"_count\":1,\"endCursor\":\"\",\"hasNextPage\":\"False\"}"
}
}
(That is the corrects data from the Cosmos DB)
When I put the query return type back to what I want it to be...
Query:
type Query{
books(id: Int!): [Book]
}
Resolver: Same as before
Query: Same as before
Result:
{
"errors": [
{
"message": "Error trying to resolve field 'books'.",
"locations": [
{
"line": 2,
"column": 2
}
],
"path": [
"books"
],
"extensions": {
"code": "JSON_READER",
"codes": [
"JSON_READER"
]
}
}
],
"data": {
"books": null
}
}
Am I meant to be using the <set-body> tag to map the "items" array out the response myself?
Is there a way to make it automatically just return the items array, or am I meant to be caring about the "_rid" value for some reason?