GraphQL: @ApiProperty(required=false) does not work
See original GitHub issueIn my Entity, I have a property:
/**
* @var int The account balance
*
* @ORM\Column(type="integer")
* @ApiProperty(required=false)
* @Assert\Type(type="integer")
*/
private $balance = 0;
I want this property to be optional in my GraphQL query, but not in database.
So I added the required=false attributes, but it doesn’t work.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Types and Parameters - OpenAPI - Documentation | NestJS
Hint Instead of explicitly typing the @ApiProperty({ required: false }) you can use the @ApiPropertyOptional() short-hand decorator.
Read more >Parameter(required = false) not working in swagger open api v3
my problem is with annotation @Parameter that belongs to io.swagger.v3.oas.annotations.Parameter. by default should be required = false, but as ...
Read more >CLI Plugin - OpenAPI - A progressive Node.js framework
The Swagger plugin will automatically: annotate all DTO properties with @ApiProperty unless @ApiHideProperty is used; set the required property depending on ...
Read more >Setting up a Hybrid REST & GraphQL API with NestJS and ...
Both of them offer fantastic typing for querying and inserting/updating data, but TypeORM has accumulated some issues over the years and was ...
Read more >OpenAPI for your REST APIs in NestJS - notiz.dev
The setup is complete, start your Nest application npm run start:dev and visit ... @ApiProperty({ required: false, nullable: true }) name?
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

So this is still an issue? Is there at least a workaround? For example I am trying to add a property to an entity that does not need to persist to the db at all. But it’s still a required field for graphql. At least when creating. when updating this does not seam to be a problem (since the values already exist and just get rehydrated into the entity already).
I am using a boolean with a default, which also should be a case where the GraphQL input is not required.