improvement: add more NonNulls

This commit is contained in:
Zach Daniel 2020-11-11 22:53:53 -05:00
parent daf8513c26
commit cacec2de1d
No known key found for this signature in database
GPG key ID: C377365383138D4B

View file

@ -387,7 +387,7 @@ defmodule AshGraphql.Resource do
%Absinthe.Blueprint.Schema.InputValueDefinition{
name: "id",
identifier: :id,
type: :id,
type: %Absinthe.Blueprint.TypeReference.NonNull{of_type: :id},
description: "The id of the record"
}
]
@ -642,7 +642,7 @@ defmodule AshGraphql.Resource do
identifier: :id,
module: schema,
name: "id",
type: :id
type: %Absinthe.Blueprint.TypeReference.NonNull{of_type: :id}
}
attribute ->
@ -676,7 +676,14 @@ defmodule AshGraphql.Resource do
end)
|> Enum.map(fn
%{cardinality: :one} = relationship ->
type = Resource.type(relationship.destination)
type =
if relationship.type == :belongs_to && relationship.required? do
%Absinthe.Blueprint.TypeReference.NonNull{
of_type: Resource.type(relationship.destination)
}
else
Resource.type(relationship.destination)
end
%Absinthe.Blueprint.Schema.FieldDefinition{
identifier: relationship.name,