Interface SchemaGeneratorHooks

  • All Implemented Interfaces:

    
    public interface SchemaGeneratorHooks
    
                        

    Collection of all the hooks when generating a schema.

    Hooks are lifecycle events that are called and triggered while the schema is building that allow users to customize the schema.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      GraphQLSchema.Builder willBuildSchema(List<TopLevelObject> queries, List<TopLevelObject> mutations, List<TopLevelObject> subscriptions, Set<KType> additionalTypes, Set<KType> additionalInputTypes, TopLevelObject schemaObject) Called before any generation of GraphQL schema.
      GraphQLType willGenerateGraphQLType(KType type) Called before using reflection to generate the graphql object type for the given KType.
      GraphQLDirective willGenerateDirective(DirectiveMetaInformation directiveInfo) Called before generating a directive annotation information to the GraphQL directive.
      GraphQLAppliedDirective willApplyDirective(DirectiveMetaInformation directiveInfo, GraphQLDirective directive) Called before transforming directive definition to applied directive.
      GraphQLType willAddGraphQLTypeToSchema(KType type, GraphQLType generatedType) Called after using reflection to generate the graphql object type but before returning it to the schema builder.
      KType willResolveMonad(KType type) Called before resolving a return type to the GraphQL type.
      KType willResolveInputMonad(KType type) Called before resolving an input type to the input GraphQL type.
      Boolean isValidSuperclass(KClass<?> kClass) Called when looking at the KClass superclasses to determine if it valid for adding to the generated schema.
      Boolean isValidProperty(KClass<?> kClass, KProperty<?> property) Called when looking at the KClass properties to determine if it valid for adding to the generated schema.
      Boolean isValidFunction(KClass<?> kClass, KFunction<?> function) Called when looking at the KClass functions to determine if it valid for adding to the generated schema.
      Boolean isValidSubscriptionReturnType(KClass<?> kClass, KFunction<?> function) Called when looking at the subscription functions to determine if it is using a valid return type.
      Boolean isValidAdditionalType(KClass<?> kClass, Boolean inputType) Allow for custom logic when adding additional types to filter out specific classes or classes with other annotations or metadata.
      GraphQLSchemaElement onRewireGraphQLType(GraphQLSchemaElement generatedType, FieldCoordinates coordinates, GraphQLCodeRegistry.Builder codeRegistry) Called after willGenerateGraphQLType and before didGenerateGraphQLType.
      GraphQLType didGenerateGraphQLType(KType type, GraphQLType generatedType) Called after wrapping the type based on nullity but before adding the generated type to the schema
      GraphQLDirective didGenerateDirective(DirectiveMetaInformation directiveInfo, GraphQLDirective directive) Called after auto-generating the directive definition from the annotation that allows final transformation before it is added to the schema document.
      GraphQLAppliedDirective didApplyDirective(DirectiveMetaInformation directiveInfo, GraphQLAppliedDirective directive) Called after transforming directive definition to applied directive that allows for final transformation before it is applied to a target location.
      GraphQLFieldDefinition didGenerateQueryField(KClass<?> kClass, KFunction<?> function, GraphQLFieldDefinition fieldDefinition) Called after converting the function to a field definition but before adding to the query object to allow customization.
      GraphQLFieldDefinition didGenerateMutationField(KClass<?> kClass, KFunction<?> function, GraphQLFieldDefinition fieldDefinition) Called after converting the function to a field definition but before adding to the mutation object to allow customization.
      GraphQLFieldDefinition didGenerateSubscriptionField(KClass<?> kClass, KFunction<?> function, GraphQLFieldDefinition fieldDefinition) Called after converting the function to a field definition but before adding to the subscription object to allow customization.
      GraphQLObjectType didGenerateQueryObject(GraphQLObjectType type) Called after generating the Query object but before adding it to the schema.
      GraphQLObjectType didGenerateMutationObject(GraphQLObjectType type) Called after generating the Mutation object but before adding it to the schema.
      GraphQLObjectType didGenerateSubscriptionObject(GraphQLObjectType type) Called after generating the Subscription object but before adding it to the schema.
      GraphQLSchema.Builder didBuildSchema(GraphQLSchema.Builder builder) Called after generation of schema but before returning it to the user.
      KotlinDirectiveWiringFactory getWiringFactory()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • willGenerateGraphQLType

         GraphQLType willGenerateGraphQLType(KType type)

        Called before using reflection to generate the graphql object type for the given KType. This allows supporting objects that the caller does not want to use reflection on for special handling

      • willGenerateDirective

         GraphQLDirective willGenerateDirective(DirectiveMetaInformation directiveInfo)

        Called before generating a directive annotation information to the GraphQL directive. This allows for special handling of the directive annotations.

      • willApplyDirective

         GraphQLAppliedDirective willApplyDirective(DirectiveMetaInformation directiveInfo, GraphQLDirective directive)

        Called before transforming directive definition to applied directive. This allows for special handling of the directive transformation (e.g. handling nulls, default parameters, etc).

      • willAddGraphQLTypeToSchema

         GraphQLType willAddGraphQLTypeToSchema(KType type, GraphQLType generatedType)

        Called after using reflection to generate the graphql object type but before returning it to the schema builder. This allows for modifying the type info, like description or directives

      • willResolveMonad

         KType willResolveMonad(KType type)

        Called before resolving a return type to the GraphQL type. This allows for changes in the supported return types or unwrapping of specific classes.

      • willResolveInputMonad

         KType willResolveInputMonad(KType type)

        Called before resolving an input type to the input GraphQL type. This allows for changes in the supported input values and unwrapping of custom types, like in an Optional.

      • isValidSuperclass

         Boolean isValidSuperclass(KClass<?> kClass)

        Called when looking at the KClass superclasses to determine if it valid for adding to the generated schema. If any filter returns false, it is rejected.

      • isValidProperty

         Boolean isValidProperty(KClass<?> kClass, KProperty<?> property)

        Called when looking at the KClass properties to determine if it valid for adding to the generated schema. If any filter returns false, it is rejected.

      • isValidFunction

         Boolean isValidFunction(KClass<?> kClass, KFunction<?> function)

        Called when looking at the KClass functions to determine if it valid for adding to the generated schema. If any filter returns false, it is rejected.

      • isValidSubscriptionReturnType

         Boolean isValidSubscriptionReturnType(KClass<?> kClass, KFunction<?> function)

        Called when looking at the subscription functions to determine if it is using a valid return type. By default, graphql-java supports org.reactivestreams.Publisher in the subscription execution strategy. If you want to provide a custom execution strategy, you may need to override this hook.

        NOTE: You will most likely need to also override the willResolveMonad hook to allow for your custom type to be generated.

      • isValidAdditionalType

         Boolean isValidAdditionalType(KClass<?> kClass, Boolean inputType)

        Allow for custom logic when adding additional types to filter out specific classes or classes with other annotations or metadata.

        The default logic just filters out interfaces if inputType is true.

      • onRewireGraphQLType

         GraphQLSchemaElement onRewireGraphQLType(GraphQLSchemaElement generatedType, FieldCoordinates coordinates, GraphQLCodeRegistry.Builder codeRegistry)

        Called after willGenerateGraphQLType and before didGenerateGraphQLType. Enables you to change the wiring, e.g. apply directives to alter the target type.

      • didGenerateGraphQLType

         GraphQLType didGenerateGraphQLType(KType type, GraphQLType generatedType)

        Called after wrapping the type based on nullity but before adding the generated type to the schema

      • didGenerateDirective

         GraphQLDirective didGenerateDirective(DirectiveMetaInformation directiveInfo, GraphQLDirective directive)

        Called after auto-generating the directive definition from the annotation that allows final transformation before it is added to the schema document.

      • didApplyDirective

         GraphQLAppliedDirective didApplyDirective(DirectiveMetaInformation directiveInfo, GraphQLAppliedDirective directive)

        Called after transforming directive definition to applied directive that allows for final transformation before it is applied to a target location.

      • didGenerateQueryField

         GraphQLFieldDefinition didGenerateQueryField(KClass<?> kClass, KFunction<?> function, GraphQLFieldDefinition fieldDefinition)

        Called after converting the function to a field definition but before adding to the query object to allow customization.

      • didGenerateMutationField

         GraphQLFieldDefinition didGenerateMutationField(KClass<?> kClass, KFunction<?> function, GraphQLFieldDefinition fieldDefinition)

        Called after converting the function to a field definition but before adding to the mutation object to allow customization.

      • didGenerateSubscriptionField

         GraphQLFieldDefinition didGenerateSubscriptionField(KClass<?> kClass, KFunction<?> function, GraphQLFieldDefinition fieldDefinition)

        Called after converting the function to a field definition but before adding to the subscription object to allow customization.

      • didGenerateQueryObject

         GraphQLObjectType didGenerateQueryObject(GraphQLObjectType type)

        Called after generating the Query object but before adding it to the schema.

      • didGenerateMutationObject

         GraphQLObjectType didGenerateMutationObject(GraphQLObjectType type)

        Called after generating the Mutation object but before adding it to the schema.

      • didGenerateSubscriptionObject

         GraphQLObjectType didGenerateSubscriptionObject(GraphQLObjectType type)

        Called after generating the Subscription object but before adding it to the schema.

      • didBuildSchema

         GraphQLSchema.Builder didBuildSchema(GraphQLSchema.Builder builder)

        Called after generation of schema but before returning it to the user. This doesn't prevent the called from rebuilding the final schema using java-graphql's functionality