【发布时间】:2021-08-03 07:13:53
【问题描述】:
我有通知表,其中数据字段存储为 json :
{"data":{"description":"Event Status has been changed to pending","event_id":19}}
我收到此错误
"errors": [
{
"debugMessage": "Expected a value of type \"String\" but received: {\"data\":{\"description\":\"Event Status has been changed to pending\",\"event_id\":19}}",
我尝试在通知模型上添加以下内容:
public function getDataAttribute($data)
{
return json_decode($data, true);
}
但没有解决办法。
我尝试在 GraphQL 架构中使用 [String],但没有。
【问题讨论】:
-
您试图将对象/数组/记录 - [复杂] graphql 中的单独类型 - 作为单个字符串返回?没办法...使用 自定义 json 标量 stackoverflow.com/a/62647404/6124657 ?
标签: graphql laravel-lighthouse