The schema validator should catch nested non_null field definitions at compile time.
It doesn't actually do the above.
Sample field definition that highlights this unexpected behaviour.
field(:permissions, non_null(list_of(non_null(non_null(:string)))))
I can create a PR for this provided someone can give me pointers on where to start.
If I understand you have a list of structures, which you want to validate.
It's not gonna work as expected; field(:permissions, non_null(list_of(non_null(:string)))) works fine because your list contains string who cannot be null.
If you try (non_null(non_null(:string)) expecting to validate an object, it will fail. Because it doesn't know which field it should check against if your object has multiples fields. ie:
foo {
bar: "x",
baz: "y"
}
If you want to check your structure fields one better approach. First, create a type which contains the fields you want to validate:
... module
input_object :foo_input do
field :bar, non_null(:string)
field :baz, :string
end
...
After it you can create your field as a composition off your type + check as:
field(:permission, non_null(list_of(non_null(:foo_input)))
It will not allow:
non_null in your input_object (the only bar in this case).I think you misunderstood the issue. All I'm saying here is
field(:permissions, non_null(list_of(non_null(non_null(:string)))))
is invalid, and should be caught at compile time. Unfortunately that's not the case.
Wow, clearly I did, so ignore my response.
Most helpful comment
Fix here: https://github.com/absinthe-graphql/absinthe/pull/878