scrnhq / laravel-bakery

🍞🧑‍🍳 An on-the-fly GraphQL Schema generator from Eloquent models for Laravel.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make input field explicitly null for input

rovansteen opened this issue · comments

In 2.0 we check the default attributes for a model to see if we should make the input field nullable or not. So if the field is not nullable itself, setting a default attribute on the model will make the create input for that field nullable. This works fine for simple cases but if the default attribute is dynamic you might want to do this on the observer. I think we should respect this as the constraint that the field is not nullable will probably be on the database in that case.
I’m thinking of something like nullableOnCreation() that can be called on a field in the model scheme to define this behavior. Thoughts @erikgaal?

Sounds reasonable!