Schema.php
''' $ films = new ObjectType([ 'name'=>'filmsdetails',
'fields' => [
'id' => Type::int(),
'name' => Type::string(),
'uniq_id' => Type::string(),
'language' => Type::string(),
'rating' => Type::string(),
'country' => Type::string(),
'genre' => Type::string(),
'permalink' => Type::string(),
'alias_name' => Type::string(),
'story' => Type::string(),
'moviestream' => [
'type' => Type::listOf($moviestream),
],
]
]);
$ moviestream = new ObjectType([ 'name'=>'moviestream_details'
'fields' => [
'id' => Type::string(),
'movie_id' => Type::string(),
'video_quality' => Type::string(),
'full_movie' => Type::string(),
'full_movie_url' => Type::string(),
'thirdparty_url' => Type::string(),
'studio_id' => Type::string(),
'sdk_user_id' => Type::string(),
'review_flag' => Type::string(),
] ]);
'''
查询类型
$queryType = new ObjectType([
'name' => 'Query',
'fields' => [
'getContentDetails' => [
'type' => Type::listOf($films),
'args' => [
'content_types_id' => Type::string(),
'oauth_token' => Type::string(),
'permalink' => Type::string(),
],
'resolve' => function ($root,$args) {
$oauth_token = Oauth::model()->getOauthToken($args["oauth_token"]);
if($oauth_token['oauth_token'] == $args["oauth_token"]){
$user = UserData::model()->getUser($args['permalink'],$oauth_token['studio_id']);
$returnArray = [];
foreach($user as $key => $data) {
// echo '<script>';
// echo 'console.log('. json_encode($data) .')';
// echo '</script>';
// $enddatecondition = Yii::app()->contentCommon->getLiveEndDateCondition('ms');
if ($data["permalink"] == $args["permalink"] && $data["content_types_id"] == $args["content_types_id"]){
$returnArray = $user;
}
return $user;
}
}
}
],
],
]);
这里$ films和$ moviestream都是模式类型。在$ films中,我试图访问$ moviestream的数据。
在querytype中,我正在从模型中获取数据。但是它显示了一些错误,即:“期望null为GraphQL类型。”
如何解决?