-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix primary key delimiter verificatoin step
docs: improve docs on unions
- Loading branch information
1 parent
c6db0fc
commit ca2e534
Showing
5 changed files
with
49 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
defmodule AshGraphql.Resource.Verifiers.RequirePkeyDelimiter do | ||
# Ensures that the resource has a primary key called `id` | ||
@moduledoc false | ||
|
||
use Spark.Dsl.Verifier | ||
|
||
alias Spark.Dsl.Verifier | ||
|
||
def verify(dsl) do | ||
if Verifier.get_persisted(dsl, :embedded?) do | ||
:ok | ||
else | ||
primary_key = | ||
dsl | ||
|> Verifier.get_entities([:attributes]) | ||
|> Enum.filter(& &1.primary_key?) | ||
|
||
case primary_key do | ||
[_single] -> | ||
:ok | ||
|
||
[_ | _] -> | ||
if Verifier.get_persisted(dsl, :primary_key) do | ||
:ok | ||
else | ||
module = Verifier.get_persisted(dsl, :module) | ||
|
||
raise Spark.Error.DslError, | ||
module: module, | ||
path: [:graphql, :primary_key_delimiter], | ||
message: | ||
"AshGraphql requires a `primary_key_delimiter` to be set for composite primary keys." | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters