There is a JSON array:
[{
"src":{
"hd":"1.jpeg",
"small":"2.jpeg"
}},
{
"src":{
"hd":"1.jpeg",
"small":"2.jpeg"
}
}]
How do I get the list through GraphQL? I don't know how many elements there are.
I can get a one dimensional array with pictures:
$pictures = new ObjectType(
[
'name' => 'pictures',
'fields' => [
'small' => [
'type' => Type::string(),
],
'hd' => [
'type' => Type::string(),
],
]
]
);
return [
......
'image' => [
'type' => $pictures,
'is_relation' => false,
'resolve' => function ($content) {
return $content->image[0]; // I return one here, but I need a list
},
],
......
But how can I get an array of pictures if I don't know how many there are? Maybe one picture, maybe 10.
Googled for half a day, found information that GraphQL can return only what is hardcoded... Is it so?
question from:
https://stackoverflow.com/questions/65918881/how-can-i-return-an-array-in-graphql-if-i-dont-know-how-many-there-are-php-re 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…