Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow null attributes in ApiResource, ApiProperty and Operations #4422

Closed
wants to merge 3 commits into from

Conversation

mtarld
Copy link
Contributor

@mtarld mtarld commented Sep 6, 2021

Q A
Branch? main
Tickets #4411
License MIT

ApiProperty is already ok

@mtarld mtarld changed the title Allow null attributes in ApiResource Allow null attributes in ApiResource and ApiProperty Sep 6, 2021
@mtarld
Copy link
Contributor Author

mtarld commented Sep 6, 2021

We need to handle as well

  • ApiPlatform\Metadata\Operation
  • ApiPlatform\Metadata\Get
  • ApiPlatform\Metadata\GetCollection
  • ApiPlatform\Metadata\Post
  • ApiPlatform\Metadata\Put
  • ApiPlatform\Metadata\Patch
  • ApiPlatform\Metadata\Delete
  • ApiPlatform\Metadata\GraphQl\Operation
  • ApiPlatform\Metadata\GraphQl\Query
  • ApiPlatform\Metadata\GraphQl\QueryCollection
  • ApiPlatform\Metadata\GraphQl\Mutation
  • ApiPlatform\Metadata\GraphQl\Subscription

@mtarld mtarld changed the title Allow null attributes in ApiResource and ApiProperty Allow null attributes in ApiResource, ApiProperty and Operations Sep 6, 2021
Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there is a design issue. The getters can return null, but it's not possible to pass null to the withers (as in https://github.com/api-platform/core/blob/main/src/Core/Metadata/Resource/ResourceMetadata.php).

null is a special value saying "this property hasn't been defined yet". Once it's define, it cannot be reset.

@dunglas
Copy link
Member

dunglas commented Sep 7, 2021

Also, I think that all default values should be null, or it's almost useless to make them nullable.

@soyuka
Copy link
Member

soyuka commented Sep 23, 2021

superseeded by #4449 thanks @mtarld !

@soyuka soyuka closed this Sep 23, 2021
@mtarld mtarld deleted the feature/null-attributes branch September 23, 2021 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants