Skip to content

Extend the TypeFunction API to be more flexible #81

@cvolzke

Description

@cvolzke

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions