From fa84e7eccade7106c5f8503e8a99554a2ebdbcf8 Mon Sep 17 00:00:00 2001 From: Barnabas Jovanovics Date: Tue, 22 Aug 2023 10:17:07 +0200 Subject: [PATCH] fix: get allow_nil? from the correct place --- lib/resource/resource.ex | 12 ++++++------ test/support/resources/constrained_map.ex | 4 +--- test/support/resources/map_types.ex | 8 ++------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/resource/resource.ex b/lib/resource/resource.ex index ffae4a0b..d34d1e8f 100644 --- a/lib/resource/resource.ex +++ b/lib/resource/resource.ex @@ -2456,7 +2456,7 @@ defmodule AshGraphql.Resource do name: to_string(name), type: if Keyword.get( - constraints || [], + attribute, :allow_nil?, true ) do @@ -2471,7 +2471,7 @@ defmodule AshGraphql.Resource do ] } - {type, constraints} -> + {type, _} -> {types, [ %Absinthe.Blueprint.Schema.FieldDefinition{ @@ -2481,7 +2481,7 @@ defmodule AshGraphql.Resource do name: to_string(name), type: if Keyword.get( - constraints || [], + attribute, :allow_nil?, true ) do @@ -2538,7 +2538,7 @@ defmodule AshGraphql.Resource do __reference__: AshGraphql.Resource.ref(env), name: to_string(name), type: - if Keyword.get(constraints || [], :allow_nil?, true) do + if Keyword.get(attribute, :allow_nil?, true) do nested_type_name else %Absinthe.Blueprint.TypeReference.NonNull{ @@ -2550,7 +2550,7 @@ defmodule AshGraphql.Resource do ] } - {type, constraints} -> + {type, _} -> {types, [ %Absinthe.Blueprint.Schema.InputValueDefinition{ @@ -2559,7 +2559,7 @@ defmodule AshGraphql.Resource do __reference__: AshGraphql.Resource.ref(env), name: to_string(name), type: - if Keyword.get(constraints || [], :allow_nil?, true) do + if Keyword.get(attribute, :allow_nil?, true) do do_field_type(type, nil, nil, false) else %Absinthe.Blueprint.TypeReference.NonNull{ diff --git a/test/support/resources/constrained_map.ex b/test/support/resources/constrained_map.ex index 70328759..1a91775e 100644 --- a/test/support/resources/constrained_map.ex +++ b/test/support/resources/constrained_map.ex @@ -6,9 +6,7 @@ defmodule AshGraphql.Test.ConstrainedMap do fields: [ foo_bar: [ type: :string, - constraints: [ - allow_nil?: false - ] + allow_nil?: false ], baz: [ type: :integer diff --git a/test/support/resources/map_types.ex b/test/support/resources/map_types.ex index bc66e1d1..f11ae12c 100644 --- a/test/support/resources/map_types.ex +++ b/test/support/resources/map_types.ex @@ -12,9 +12,7 @@ defmodule AshGraphql.Test.MapTypes do fields: [ foo: [ type: :string, - constraints: [ - allow_nil?: false - ] + allow_nil?: false ], bar: [ type: :integer @@ -43,9 +41,7 @@ defmodule AshGraphql.Test.MapTypes do fields: [ foo: [ type: :string, - constraints: [ - allow_nil?: false - ] + allow_nil?: false ], bar: [ type: :integer