-
Notifications
You must be signed in to change notification settings - Fork 96
Closed
Description
Custom TypeFunctions are presently registered by java class. If I want to create my own TypeFunction, I must implement getAcceptedTypes and return exactly the classes I support creating graphql types for:
Collection<Class<?>> getAcceptedTypes();
This isn't a very flexible design and doesn't allow for type functions for:
- Map<ApiEnum, *>. I want to generate a type where the key is ApiEnum, but I don't want to build types for other Map objects
- All implementors of a specific interface
- A type that has so and so annotation(s)
- etc
To work around this, we've created our own 'type function' concept that has canBuildType and buildType methods. Instead of looking up the type function from a Map<Class, TypeFunction>, we iterate through all known TypeFunction objects calling canBuildType until there is a match. This satisfies the use cases listed above.
Metadata
Metadata
Assignees
Labels
No labels