@@ -3317,7 +3317,7 @@ defmodule AshGraphql.Resource do
33173317 [
33183318 input_type_name
33193319 ]
3320- |> define_input_map_types ( constraints , schema , env )
3320+ |> define_input_map_types ( constraints , schema , resource , env )
33213321 )
33223322 end )
33233323 else
@@ -3342,7 +3342,7 @@ defmodule AshGraphql.Resource do
33423342 Ash.Type.Struct
33433343 ] )
33443344
3345- if map_type? && attribute [ :constraints ] not in [ nil , [ ] ] do
3345+ if map_type? && attribute [ :constraints ] [ :fields ] do
33463346 nested_type_name =
33473347 String . to_atom ( "#{ Atom . to_string ( type_name ) } _#{ Atom . to_string ( name ) } " )
33483348
@@ -3418,20 +3418,26 @@ defmodule AshGraphql.Resource do
34183418 ) do
34193419 do_field_type (
34203420 attribute [ :type ] ,
3421- nil ,
3422- nil ,
3423- false ,
3424- Keyword . get ( attribute , :constraints ) || [ ]
3421+ % {
3422+ name: name ,
3423+ type: attribute [ :type ] ,
3424+ constraints: Keyword . get ( attribute , :constraints ) || [ ]
3425+ } ,
3426+ resource ,
3427+ false
34253428 )
34263429 else
34273430 % Absinthe.Blueprint.TypeReference.NonNull {
34283431 of_type:
34293432 do_field_type (
34303433 attribute [ :type ] ,
3431- nil ,
3432- nil ,
3433- false ,
3434- Keyword . get ( attribute , :constraints ) || [ ]
3434+ % {
3435+ name: name ,
3436+ type: attribute [ :type ] ,
3437+ constraints: Keyword . get ( attribute , :constraints ) || [ ]
3438+ } ,
3439+ resource ,
3440+ false
34353441 )
34363442 }
34373443 end
@@ -3455,7 +3461,7 @@ defmodule AshGraphql.Resource do
34553461 end
34563462
34573463 # sobelow_skip ["DOS.StringToAtom"]
3458- defp define_input_map_types ( input_type_names , constraints , schema , env ) do
3464+ defp define_input_map_types ( input_type_names , constraints , schema , resource , env ) do
34593465 input_type_names
34603466 |> Enum . filter ( & & 1 )
34613467 |> Enum . flat_map ( fn type_name ->
@@ -3471,7 +3477,7 @@ defmodule AshGraphql.Resource do
34713477 Ash.Type.Struct
34723478 ] )
34733479
3474- if map_type? && attribute [ :constraints ] not in [ nil , [ ] ] do
3480+ if map_type? && attribute [ :constraints ] [ :fields ] do
34753481 nested_type_name =
34763482 String . to_atom (
34773483 "#{ Atom . to_string ( type_name ) |> String . replace ( "_input" , "" ) } _#{ Atom . to_string ( name ) } _input"
@@ -3482,6 +3488,7 @@ defmodule AshGraphql.Resource do
34823488 [ nested_type_name ] ,
34833489 attribute [ :constraints ] || [ ] ,
34843490 schema ,
3491+ resource ,
34853492 env
34863493 ) ++ types ,
34873494 [
@@ -3514,20 +3521,26 @@ defmodule AshGraphql.Resource do
35143521 if Keyword . get ( attribute , :allow_nil? , true ) do
35153522 do_field_type (
35163523 attribute [ :type ] ,
3517- nil ,
3518- nil ,
3519- true ,
3520- attribute [ :constraints ] || [ ]
3524+ % {
3525+ name: name ,
3526+ type: attribute [ :type ] ,
3527+ constraints: Keyword . get ( attribute , :constraints ) || [ ]
3528+ } ,
3529+ resource ,
3530+ true
35213531 )
35223532 else
35233533 % Absinthe.Blueprint.TypeReference.NonNull {
35243534 of_type:
35253535 do_field_type (
35263536 attribute [ :type ] ,
3527- nil ,
3528- nil ,
3529- true ,
3530- attribute [ :constraints ] || [ ]
3537+ % {
3538+ name: name ,
3539+ type: attribute [ :type ] ,
3540+ constraints: Keyword . get ( attribute , :constraints ) || [ ]
3541+ } ,
3542+ resource ,
3543+ true
35313544 )
35323545 }
35333546 end
@@ -4642,7 +4655,7 @@ defmodule AshGraphql.Resource do
46424655 # Due to ash not automatically adding the default array constraints to
46434656 # types defined outside of an `attribute` we need to default to true here
46444657 # and not to false.
4645- nil_items? = Keyword . get ( constraints , :nil_items? , true )
4658+ nil_items? = Keyword . get ( constraints || [ ] , :nil_items? , true )
46464659
46474660 field_type =
46484661 do_field_type ( type , nil , resource , input? , constraints [ :items ] || [ ] )
0 commit comments