There’s been a pretty reasonable analogy between raising a graphql error and raising an exception. Functions can raise an exception OR return successfully, but not both. If you want to return error information as well as result information the general convention is to have a specific object type that composes both.
I don’t understand your answer. My function does not return any errors (as far as I know). It’s the absinthe library that returns the error that it doesn’t find the ```
adhocEnabled
field. In the same message it suggest to use the ```
adhocEnabled
object :serviceProvider do
field :name, non_null(:string)
field :adhocEnabled, non_null(:boolean)
field :adhocCost, non_null(:float)
field :subEnabled, non_null(:boolean)
field :subCost, non_null(:float)
end
Apparently if I use camelCase field names, absinthe uses snake_case column names in the database and somehow, somewhere it fails to convert between the names. So probably one of the adhocEnabled strings in the error message is in fact adhoc_enabled, it’s only absinthe that “helpfully” converts the names. If I use snake_case field names, everything seems to work.