-
Notifications
You must be signed in to change notification settings - Fork 322
Description
The issue is the integration between spring-graphql and spring-data, which is activated only when spring-data is in the classpath.
In particular there appears to be an intrusive bug - the GraphQlDataAutoConfiguration
class registers a ConnectionFieldTypeVisitor
that modifies all DataFetchers
that return a Connection
type to add various paging information. In particular, in adaptDataContainer()
, if the returned value is null
it systematically replaces the return value with an EMPTY_CONNECTION
, a DefaultConnection
object.
However, not all graphql datafetchers come from spring-data, and when the schema doesn't have a !
on the connection return type, it's perfectly legal and often desirable to return a null
response when there aren't any relationships.
Adding spring-data onto our app's classpath triggers this, and is introducing a regression in our APIs which expect a null response value.
I've found a workaround which is to register a dummy cursorStrategy
bean that overrides the one from the spring-graphql spring-data integration, but this means that the integration isn't usable (we're not currently using it).
A fix would appear to be to either leave a null-value as-is, or, if there can be a situation where the DB response returns null when there is no data (would be surprising), check if there is a non-nullable !
in the schema and only return an empty connection when the response value is specified as "must be non-null".