GraphQL NewType Non-null?

I'm surfacing a calculated map as its own type in GraphQL and trying to make the fields non-nullable, but can't seem to get it working. I've also tried dropping the allow_nil?s into constraints key. Am I holding it wrong?
defmodule MyApp.Types.LatLng do
use Ash.Type.NewType,
subtype_of: :map,
constraints: [
fields: [
lat: [type: :float, allow_nil?: false],
lng: [type: :float, allow_nil?: false]
]
]

def graphql_type(_), do: :lat_lng
end
defmodule MyApp.Types.LatLng do
use Ash.Type.NewType,
subtype_of: :map,
constraints: [
fields: [
lat: [type: :float, allow_nil?: false],
lng: [type: :float, allow_nil?: false]
]
]

def graphql_type(_), do: :lat_lng
end
No description
4 Replies
ZachDaniel
ZachDaniel2y ago
@barnabasj implemented this, they may be able to provide some support
barnabasj
barnabasj2y ago
Let me check today
barnabasj
barnabasj2y ago
Looks like i missed this in my implementation. I prepared a PR with the necessary changes https://github.com/ash-project/ash_graphql/pull/90
GitHub
fix: wrap type in non-null reference if allow_nil? is set to false ...
Contributor checklist Bug fixes include regression tests
skander
skanderOP2y ago
Thank you! Just tried it, works perfectly. Thanks again!

Did you find this page helpful?