I have got an graphql query coming back from aws's appsync service. This is the json that comes back from the query.
{
"data": {
"listPeople": {
"items": [
{
"age": 23,
"id": "123",
"name": "BobTest",
"__typename": "Person"
},
{
"age": 24,
"id": "124",
"name": "JoeTest",
"__typename": "Person"
},
{
"age": 25,
"id": "125",
"name": "JimTest",
"__typename": "Person"
}
],
"__typename": "PersonConnection"
}
}
}
This is what it looks like logged to the console.
This is the query response in apollo-dev-tools:
Error accessing items
array.
Trying to log the items
values to console by running
https://github.com/idkjs/reason-apollo-question/blob/d38e7fbc33f02ab718c7227958d88f02adba1696/src/Persons.re#L66-L70
| Data(response) =>
Js.log(response##listPeople);
let listPeople = response##listPeople;
let items = response##listPeople##items;
Js.log(items);
produces this error:
We've found a bug for you!
/Users/prisc_000/code/REASON/APOLLO/reason-apollo-question/src/Persons.re 69:32-51
67 ┆ Js.log(response##listPeople);
68 ┆ let listPeople = response##listPeople;
69 ┆ let items = response##listPeople##items;
70 ┆ Js.log(items);
71 ┆
This has type:
option({. "items": option(Js.Array.t(option(
{. "age": int, "id": string, "name": string})))
})
But somewhere wanted:
Js.t('a)
ninja: build stopped: subcommand failed.
>>>> Finish compiling(exit: 1)
How do I resolve this type error?
Thank you!