Description
Hello!
We just rewrote our entire platform from DGS to Spring GraphQL and generally we are very happy with what you have built here! We just stumbled upon one bug we had caused by misconfiguration that got kind of buried in the runtime errors where I think a louder crash upon launch maybe should be preferable.
The "problem"
In short: We had a copy paste error in one of our @EntityMapping
declarations for a federated entity, and the result was that some of our federated queries failed without any loud exception simply with the error message No entity fetcher
. We noticed eventually because some of our outer use cases failed, of course, but I wonder if the library could detect this problem earlier and complain super-loudly. I think DGS does this, but I am not 100% sure.
In detail, here's what happens (if I read the code correctly):
- If there is a missing
@EntityMapping
, then the EntitiesDataFetcher produces a regular GraphQL error - This, I assume, is to possibly be able to produce values for any entities that are NOT missing a handler
The suggestion
What if FederationSchemaFactory
could (either in afterPropertiesSet
or createSchemaTransformer
or similar), double check that the list of provided @EntityMapping
covers all the declared, resolvable, federated entities (types with @key(..., resolvable: true)
), and if not crash with a user friendly exception?
Unless I am missing something, this should be the behaviour one would want, because if you didn't want an @EntityMapping
, then you likely should mark the entity in the schema as resolvable: false
. And my experience in general with Spring is that it is very good at complaining loudly with a clear explanation when there is a suspected misconfiguration.
More specifically in our case - the copy-paste error we had meant that we have DUPLICATE @EntityMapping
declarations for the same time - which also didn't produce any kind of warning or error - which itself maybe should've been an error.
Let me know what you think, and whether you are open to me making an attempt at building this myself and sending a PR.