-
- 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.
-
-
Method Summary
Modifier and Type Method Description GraphQLSchema.Builder
willBuildSchema(GraphQLSchema.Builder builder)
Called before the final GraphQL schema is built. GraphQLType
willGenerateGraphQLType(KType type)
Called before using reflection to generate the graphql object type for the given KType. 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 beforedidGenerateGraphQLType
.GraphQLType
didGenerateGraphQLType(KType type, GraphQLType generatedType)
Called after wrapping the type based on nullity but before adding the generated type to the schema 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. KotlinDirectiveWiringFactory
getWiringFactory()
-
-
Method Detail
-
willBuildSchema
GraphQLSchema.Builder willBuildSchema(GraphQLSchema.Builder builder)
Called before the final GraphQL schema is built. This doesn't prevent the called from rebuilding the final schema using java-graphql's functionality
-
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
-
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 beforedidGenerateGraphQLType
. 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
-
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.
-
getWiringFactory
KotlinDirectiveWiringFactory getWiringFactory()
-
-
-
-