I have the following Graphql Container:
let ste = ReasonReact.string;
type listMatches = {
/** Foo */
date: option(string),
homeTeam: option({. "name": option(string)}),
awayTeam: option({. "name": option(string)}),
homeScore: option(int),
awayScore: option(int),
goals:
option(
Js.Array.t(
option({
.
"scorer": option({. "name": option(string)}),
"time": option(string),
}),
),
),
};
module GetMatches = [%graphql
{|
query getMatches($id: Int!){
matches(id: $id){
date
homeTeam {name}
awayTeam {name}
homeScore
awayScore
goals {
scorer {
name
}
time
}
}
}
|}
];
module GetMatchesQuery = ReasonApollo.CreateQuery(GetMatches);
let component = ReasonReact.statelessComponent("Matches");
let make = _children => {
...component,
render: _self => {
let matchParam = GetMatches.make(~id=300331511, ());
<GetMatchesQuery variables=matchParam##variables>
...{
({result}) =>
<div>
{
switch (result) {
| Error(e) =>
Js.log(e);
"Something Went Wrong" |> ste;
| Loading => "Loading" |> ste
| Data(response) =>
switch (response##matches) {
| None => "No Person Data" |> ste
| Some(person) => <div> {person##date |> ste} </div>
}
}
}
</div>
}
</GetMatchesQuery>;
},
};
But I keep getting this error:
Error: This expression has type
Js.Array.t(option({. "awayScore": option(int),
"awayTeam": option({. "name": option(string)}),
"date": option(string),
"goals": option(Js.Array.t(option({. "scorer":
option(
{. "name":
option(
string)}),
"time":
option(
string)}))),
"homeScore": option(int),
"homeTeam": option({. "name": option(string)})}))
=
array(option({. "awayScore": option(int),
"awayTeam": option({. "name": option(string)}),
"date": option(string),
"goals": option(Js.Array.t(option({. "scorer":
option(
{. "name":
option(
string)}),
"time":
option(
string)}))),
"homeScore": option(int),
"homeTeam": option({. "name": option(string)})}))
but an expression was expected of type Js.t('a)
[merlin]
I’ve tried passing the response to an array but the error is the same…how am I supposed to parse this and display it?