Enigmatis / graphql-java-annotations

GraphQL Annotations for Java
Other
387 stars 97 forks source link

Fix union #165

Closed guy120494 closed 6 years ago

guy120494 commented 6 years ago

Now union type can have a TypeResolver. I also added a default TypeResolver that resolves the type by its name, i.e: The DB and API entities must have similar names, up to "API" suffix in the API entity's name

@yarinvak @tdraier as usual, please CR me

guy120494 commented 6 years ago

The problem was that getObject returns a DB entity, and if you have different classes for DB and API entities (as you should), the type resovler will not match any of the possibilities. The most reasonable defalut behaviour I could think of is trying to match a possibility by name, because in most cases the DB name and API are similar (for example: CatDB and CatApi)

tdraier commented 6 years ago

Agree that the problem is that getObject returns a "DB" entity. If by DB you mean any internal/backend object, they should not be returned by any of the Api objects - and especially the DataFetcher. DataFetcher should return an object usable by the api.