graphql.schema.idl.SchemaDirectiveWiring Maven / Gradle / Ivy
package graphql.schema.idl;
import graphql.PublicApi;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLEnumType;
import graphql.schema.GraphQLEnumValueDefinition;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLInputObjectField;
import graphql.schema.GraphQLInputObjectType;
import graphql.schema.GraphQLInterfaceType;
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLScalarType;
import graphql.schema.GraphQLUnionType;
/**
* A SchemaDirectiveWiring is responsible for enhancing a runtime element based on directives placed on that
* element in the Schema Definition Language (SDL).
*
* It can enhance the graphql runtime element and add new behaviour for example by changing
* the fields {@link graphql.schema.DataFetcher}
*
* The SchemaDirectiveWiring objects are called in a specific order based on registration:
*
* - {@link graphql.schema.idl.RuntimeWiring.Builder#directive(String, SchemaDirectiveWiring)} which work against a specific named directive are called first
* - {@link graphql.schema.idl.RuntimeWiring.Builder#directiveWiring(SchemaDirectiveWiring)} which work against all directives are called next
* - {@link graphql.schema.idl.WiringFactory#providesSchemaDirectiveWiring(SchemaDirectiveWiringEnvironment)} which work against all directives are called last
*
*/
@PublicApi
public interface SchemaDirectiveWiring {
/**
* This is called when an object is encountered, which gives the schema directive a chance to modify the shape and behaviour
* of that DSL element
*
* The {@link #onArgument(SchemaDirectiveWiringEnvironment)} and {@link #onField(SchemaDirectiveWiringEnvironment)} callbacks will have been
* invoked for this element beforehand
*
* @param environment the wiring element
*
* @return a non null element based on the original one
*/
default GraphQLObjectType onObject(SchemaDirectiveWiringEnvironment environment) {
return environment.getElement();
}
/**
* This is called when a field is encountered, which gives the schema directive a chance to modify the shape and behaviour
* of that DSL element
*
* The {@link #onArgument(SchemaDirectiveWiringEnvironment)} callbacks will have been
* invoked for this element beforehand
*
* @param environment the wiring element
*
* @return a non null element based on the original one
*/
default GraphQLFieldDefinition onField(SchemaDirectiveWiringEnvironment environment) {
return environment.getElement();
}
/**
* This is called when an argument is encountered, which gives the schema directive a chance to modify the shape and behaviour
* of that DSL element
*
* @param environment the wiring element
*
* @return a non null element based on the original one
*/
default GraphQLArgument onArgument(SchemaDirectiveWiringEnvironment environment) {
return environment.getElement();
}
/**
* This is called when an interface is encountered, which gives the schema directive a chance to modify the shape and behaviour
* of that DSL element
*
* The {@link #onArgument(SchemaDirectiveWiringEnvironment)} and {@link #onField(SchemaDirectiveWiringEnvironment)} callbacks will have been
* invoked for this element beforehand
*
* @param environment the wiring element
*
* @return a non null element based on the original one
*/
default GraphQLInterfaceType onInterface(SchemaDirectiveWiringEnvironment environment) {
return environment.getElement();
}
/**
* This is called when a union is encountered, which gives the schema directive a chance to modify the shape and behaviour
* of that DSL element
*
* @param environment the wiring element
*
* @return a non null element based on the original one
*/
default GraphQLUnionType onUnion(SchemaDirectiveWiringEnvironment environment) {
return environment.getElement();
}
/**
* This is called when an enum is encountered, which gives the schema directive a chance to modify the shape and behaviour
* of that DSL element
*
* The {@link #onEnumValue(SchemaDirectiveWiringEnvironment)} callbacks will have been invoked for this element beforehand
*
* @param environment the wiring element
*
* @return a non null element based on the original one
*/
default GraphQLEnumType onEnum(SchemaDirectiveWiringEnvironment environment) {
return environment.getElement();
}
/**
* This is called when an enum value is encountered, which gives the schema directive a chance to modify the shape and behaviour
* of that DSL element
*
* @param environment the wiring element
*
* @return a non null element based on the original one
*/
default GraphQLEnumValueDefinition onEnumValue(SchemaDirectiveWiringEnvironment environment) {
return environment.getElement();
}
/**
* This is called when a custom scalar is encountered, which gives the schema directive a chance to modify the shape and behaviour
* of that DSL element
*
* @param environment the wiring element
*
* @return a non null element based on the original one
*/
default GraphQLScalarType onScalar(SchemaDirectiveWiringEnvironment environment) {
return environment.getElement();
}
/**
* This is called when an input object is encountered, which gives the schema directive a chance to modify the shape and behaviour
* of that DSL element
*
* The {@link #onInputObjectField(SchemaDirectiveWiringEnvironment)}callbacks will have been invoked for this element beforehand
*
* @param environment the wiring element
*
* @return a non null element based on the original one
*/
default GraphQLInputObjectType onInputObjectType(SchemaDirectiveWiringEnvironment environment) {
return environment.getElement();
}
/**
* This is called when an input object field is encountered, which gives the schema directive a chance to modify the shape and behaviour
* of that DSL element
*
* @param environment the wiring element
*
* @return a non null element based on the original one
*/
default GraphQLInputObjectField onInputObjectField(SchemaDirectiveWiringEnvironment environment) {
return environment.getElement();
}
}