Cannot return null for non-nullable field

Hi Guys, I have an attribute in a resource that is a jsonb object in postgres and am defaulting it to an empty object in the db and also want to return it as an emoty object in GraphQL. However it seems to be returning null if the the object is empty... Is this something AshGraphQL is doing under the hood?
4 Replies
ZachDaniel
ZachDaniel2y ago
🤔 interesting it shouldn't be The first thing to check is that it works the way you expect outside of graphql i.e write an equivalent query using Ash and run it, and make sure you're not getting back nil
barnabasj
barnabasj2y ago
I had this problem before because of field_policies in case you are using those
drumusician
drumusicianOP2y ago
code interface query returns an empty map. I am not using any field_policies ok, interesting. It is the way I am building up the query I think It is a pretty complex one where I needed to inject extra args in a related query If I query a resource directly it works, but it seems that in the relation it gets lost I'll dig up some examples
query getGamePublication($id: ID!, $organisationId: Int!) {
getGamePublication(id: $id) {
id
startParams
gameVariant(organisationId: $organisationId) {
name
id
gameVariantMeta {
displayTitle
startParams # <= when I add this on it fails
}
}
}
}
query getGamePublication($id: ID!, $organisationId: Int!) {
getGamePublication(id: $id) {
id
startParams
gameVariant(organisationId: $organisationId) {
name
id
gameVariantMeta {
displayTitle
startParams # <= when I add this on it fails
}
}
}
}
Ok, I think it is because of a calculation I'm doing ok, problem seems to be between chair and keyboard... I'm just not adding it there... 🤦‍♂️
ZachDaniel
ZachDaniel2y ago
Whats your calculation?

Did you find this page helpful?