fix: get allow_nil? from the correct place

This commit is contained in:
Barnabas Jovanovics 2023-08-22 10:17:07 +02:00
parent ff06d5a540
commit fa84e7ecca
3 changed files with 9 additions and 15 deletions

View file

@ -2456,7 +2456,7 @@ defmodule AshGraphql.Resource do
name: to_string(name), name: to_string(name),
type: type:
if Keyword.get( if Keyword.get(
constraints || [], attribute,
:allow_nil?, :allow_nil?,
true true
) do ) do
@ -2471,7 +2471,7 @@ defmodule AshGraphql.Resource do
] ]
} }
{type, constraints} -> {type, _} ->
{types, {types,
[ [
%Absinthe.Blueprint.Schema.FieldDefinition{ %Absinthe.Blueprint.Schema.FieldDefinition{
@ -2481,7 +2481,7 @@ defmodule AshGraphql.Resource do
name: to_string(name), name: to_string(name),
type: type:
if Keyword.get( if Keyword.get(
constraints || [], attribute,
:allow_nil?, :allow_nil?,
true true
) do ) do
@ -2538,7 +2538,7 @@ defmodule AshGraphql.Resource do
__reference__: AshGraphql.Resource.ref(env), __reference__: AshGraphql.Resource.ref(env),
name: to_string(name), name: to_string(name),
type: type:
if Keyword.get(constraints || [], :allow_nil?, true) do if Keyword.get(attribute, :allow_nil?, true) do
nested_type_name nested_type_name
else else
%Absinthe.Blueprint.TypeReference.NonNull{ %Absinthe.Blueprint.TypeReference.NonNull{
@ -2550,7 +2550,7 @@ defmodule AshGraphql.Resource do
] ]
} }
{type, constraints} -> {type, _} ->
{types, {types,
[ [
%Absinthe.Blueprint.Schema.InputValueDefinition{ %Absinthe.Blueprint.Schema.InputValueDefinition{
@ -2559,7 +2559,7 @@ defmodule AshGraphql.Resource do
__reference__: AshGraphql.Resource.ref(env), __reference__: AshGraphql.Resource.ref(env),
name: to_string(name), name: to_string(name),
type: type:
if Keyword.get(constraints || [], :allow_nil?, true) do if Keyword.get(attribute, :allow_nil?, true) do
do_field_type(type, nil, nil, false) do_field_type(type, nil, nil, false)
else else
%Absinthe.Blueprint.TypeReference.NonNull{ %Absinthe.Blueprint.TypeReference.NonNull{

View file

@ -6,9 +6,7 @@ defmodule AshGraphql.Test.ConstrainedMap do
fields: [ fields: [
foo_bar: [ foo_bar: [
type: :string, type: :string,
constraints: [ allow_nil?: false
allow_nil?: false
]
], ],
baz: [ baz: [
type: :integer type: :integer

View file

@ -12,9 +12,7 @@ defmodule AshGraphql.Test.MapTypes do
fields: [ fields: [
foo: [ foo: [
type: :string, type: :string,
constraints: [ allow_nil?: false
allow_nil?: false
]
], ],
bar: [ bar: [
type: :integer type: :integer
@ -43,9 +41,7 @@ defmodule AshGraphql.Test.MapTypes do
fields: [ fields: [
foo: [ foo: [
type: :string, type: :string,
constraints: [ allow_nil?: false
allow_nil?: false
]
], ],
bar: [ bar: [
type: :integer type: :integer