Mic*_*opp 5 graphql api-platform.com
我希望我的实体上的必填布尔字段具有默认值TRUE。我已将我的#api-platform属性定义如下。
#[ApiResource(
attributes: ['security' => "is_granted('ROLE_USER')"],
graphql: [
'item_query' => ['security' => "is_granted('ROLE_USER') and object.owner == user"],
'collection_query' => ['security' => "is_granted('ROLE_ADMIN')"],
'delete' => ['security' => "is_granted('ROLE_DEVELOPER')"],
'update' => ['security' => "is_granted('ROLE_DEVELOPER')"],
'create' => [
'defaults' => ['active' => TRUE],
'security' => "is_granted('ROLE_DEVELOPER')"
]
]
)]
Run Code Online (Sandbox Code Playgroud)
活动字段本身注释为
/**
* @ORM\Column(type="boolean", options={"default":true})
*/
private $active;
Run Code Online (Sandbox Code Playgroud)
这确实在数据库模式中设置了默认值,但是 GraphQL 突变似乎仍然要求在请求中提供此属性。当尝试创建一个不指定activeprop 的新实体时,我收到以下错误。
... Field value.active of required type Boolean! was not provided.
Run Code Online (Sandbox Code Playgroud)
小智 0
设置默认值不应该是这样的。
/**
* @ORM\Column(type="boolean", options={"default":true})
*/
private bool $active = true;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1106 次 |
| 最近记录: |