Skip to content

Commit

Permalink
fix: get allow_nil? from the correct place
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabasJ committed Aug 22, 2023
1 parent ff06d5a commit fa84e7e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
12 changes: 6 additions & 6 deletions lib/resource/resource.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2456,7 +2456,7 @@ defmodule AshGraphql.Resource do
name: to_string(name),
type:
if Keyword.get(
constraints || [],
attribute,
:allow_nil?,
true
) do
Expand All @@ -2471,7 +2471,7 @@ defmodule AshGraphql.Resource do
]
}

{type, constraints} ->
{type, _} ->
{types,
[
%Absinthe.Blueprint.Schema.FieldDefinition{
Expand All @@ -2481,7 +2481,7 @@ defmodule AshGraphql.Resource do
name: to_string(name),
type:
if Keyword.get(
constraints || [],
attribute,
:allow_nil?,
true
) do
Expand Down Expand Up @@ -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{
Expand All @@ -2550,7 +2550,7 @@ defmodule AshGraphql.Resource do
]
}

{type, constraints} ->
{type, _} ->
{types,
[
%Absinthe.Blueprint.Schema.InputValueDefinition{
Expand All @@ -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{
Expand Down
4 changes: 1 addition & 3 deletions test/support/resources/constrained_map.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ defmodule AshGraphql.Test.ConstrainedMap do
fields: [
foo_bar: [
type: :string,
constraints: [
allow_nil?: false
]
allow_nil?: false
],
baz: [
type: :integer
Expand Down
8 changes: 2 additions & 6 deletions test/support/resources/map_types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ defmodule AshGraphql.Test.MapTypes do
fields: [
foo: [
type: :string,
constraints: [
allow_nil?: false
]
allow_nil?: false
],
bar: [
type: :integer
Expand Down Expand Up @@ -43,9 +41,7 @@ defmodule AshGraphql.Test.MapTypes do
fields: [
foo: [
type: :string,
constraints: [
allow_nil?: false
]
allow_nil?: false
],
bar: [
type: :integer
Expand Down

0 comments on commit fa84e7e

Please sign in to comment.