Skip to content

Commit

Permalink
fix: don't include related fields in managed relationship inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Sep 19, 2023
1 parent ec3b747 commit 842e433
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/resource/resource.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,9 @@ defmodule AshGraphql.Resource do
|> Enum.map(fn field ->
{relationship.destination, action.name, field}
end)
|> Enum.reject(fn {_, _, field} ->
field.identifier == relationship.destination_attribute
end)

{:source, nil} ->
[]
Expand All @@ -1777,6 +1780,9 @@ defmodule AshGraphql.Resource do
|> Enum.map(fn field ->
{relationship.source, action.name, field}
end)
|> Enum.reject(fn {_, _, field} ->
field.identifier == relationship.source_attribute
end)

{:join, nil, _} ->
[]
Expand All @@ -1794,6 +1800,12 @@ defmodule AshGraphql.Resource do
|> Enum.map(fn field ->
{relationship.through, action.name, field}
end)
|> Enum.reject(fn {_, _, field} ->
field.identifier in [
relationship.destination_attribute_on_join_resource,
relationship.source_attribute_on_join_resource
]
end)

nil ->
[]
Expand All @@ -1816,6 +1828,9 @@ defmodule AshGraphql.Resource do
|> Enum.map(fn field ->
{relationship.destination, action.name, field}
end)
|> Enum.reject(fn {_, _, field} ->
field.identifier == relationship.destination_attribute
end)

{:join, nil, _} ->
[]
Expand All @@ -1833,6 +1848,12 @@ defmodule AshGraphql.Resource do
|> Enum.map(fn field ->
{relationship.through, action.name, field}
end)
|> Enum.reject(fn {_, _, field} ->
field.identifier in [
relationship.destination_attribute_on_join_resource,
relationship.source_attribute_on_join_resource
]
end)
end)
end

Expand All @@ -1852,6 +1873,9 @@ defmodule AshGraphql.Resource do
|> Enum.map(fn field ->
{relationship.destination, action.name, field}
end)
|> Enum.reject(fn {_, _, field} ->
field.identifier == relationship.destination_attribute
end)

{:join, nil, _} ->
[]
Expand All @@ -1869,6 +1893,12 @@ defmodule AshGraphql.Resource do
|> Enum.map(fn field ->
{relationship.through, action.name, field}
end)
|> Enum.reject(fn {_, _, field} ->
field.identifier in [
relationship.destination_attribute_on_join_resource,
relationship.source_attribute_on_join_resource
]
end)
end)
end

Expand Down

0 comments on commit 842e433

Please sign in to comment.