-
Notifications
You must be signed in to change notification settings - Fork 222
Fix Input Field annotations handling #735
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
Conversation
bartv2
commented
Aug 16, 2020
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Documented? | yes |
Fixed tickets | #... |
License | MIT |
- Skip properties without a Field annotation
- Enable field type guessing for Input annotation
This can happen when you annotate an Entity as InputType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but we should add more tests.
Also, wait for #738 & #740 to be merged.
And at the moment, the guessType
doesn't handle typed
property (it only check for doctrine annotations). We should first check for typing. Example:
classe MyType {
/**
* @GQL\Field
* @ORM\Column(type="boolean")
*/
protected int $variable;
}
In this case, we should guess the type as int
and not boolean
.
Would you mind to add this logic in this PR too ?
$fieldAnnotation = self::getFirstAnnotationMatching($annotations, GQL\Field::class); | ||
|
||
// No field annotation found | ||
if (!$fieldAnnotation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!$fieldAnnotation) { | |
if (null === $fieldAnnotation) { |
// Ignore field with resolver when the type is an Input | ||
if (isset($fieldAnnotation->resolve)) { | ||
return []; | ||
} | ||
|
||
$fieldName = $reflector->getName(); | ||
$fieldType = $fieldAnnotation->type; | ||
$fieldType = $fieldAnnotation->type ?? null; | ||
if (!$fieldType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!$fieldType) { | |
if (!isset($fieldAnnotation->type)) { |
Good job @bartv2 ! |
Something like this? |
@bartv2 Yes ! Looks good ! Just run a little |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Thank you !