Handle fields omitted through @skip or @include#3
Handle fields omitted through @skip or @include#3CRC-Mismatch wants to merge 2 commits intomasterfrom
@skip or @include#3Conversation
|
@spawnia I didn't want to pollute the original repo while testing and tweaking, so I used my own as a "test bench" for the PR checks. I did reach a solution, but I'd first like to know if my idea is on the right track in your opinion before proposing it on the original repo. This was a "K.I.S.S." solution (I could also set the fields to null, but that would require annotating them as such, and I do believe my approach would still confuse PHPStan since non-nullable properties aren't also typed as possible strings), otherwise we'd have to keep track of which fields could be omitted on each class upon generation. |
|
The fields should definitely be marked as nullable when the query has |
|
That's what I thought 🤣 and the reason I wanted to keep it separate at first... |
spawnia#77
Builds upon spawnia#79
Changes
When an operation tells the server to omit a field through @Skip or @include, the result
will not contain those fields at all. Thus, the generated result will have the missing fields set to
ObjectLike::UNDEFINEDto mark them as such.Breaking changes
Code that used to rely on exceptions being thrown when some property wasn't present in the response will need rework, as not only the exception will only be thrown if the
__typenameproperty isn't present, but also the result object will have the missing properties with thestringvalue forObjectLike::UNDEFINED.