jcrygier / graphql-jpa

JPA Implementation of GraphQL (builds on graphql-java)
MIT License
165 stars 46 forks source link

Add support for __typename introspection queries on types #32

Closed manuel-mauky closed 7 years ago

manuel-mauky commented 7 years ago

The GraphQL Spec defines that you can add a field "typename" in the query. It returns the name of the current type which can be useful for interfaces or union types. The resolver for this field is part of graphql-java. However, in graphql-jpa, quering for "typename" resulted in an exception because the data fetcher was trying to get a JPA field with this name from the entity which obviously isn't possible.

To fix this, I've added a check in the JpaDataFetcher that ignores fields with the name "__typename".