You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When wiring the default graphql.java.extended.validation setup with the RuntimeWiringConfigurer provided by the new Spring for GraphQL project, custom directives that are registered via the builders directive() method don't seem to apply anymore.
publicclassDateFormattingDirectiveimplementsSchemaDirectiveWiring {
privatestaticfinalStringFORMAT = "format";
@OverridepublicGraphQLFieldDefinitiononField(
SchemaDirectiveWiringEnvironment<GraphQLFieldDefinition> env) {
GraphQLFieldDefinitionfieldDefinition = env.getElement();
GraphQLFieldsContainerfieldsContainer = env.getFieldsContainer();
// DataFetcherFactories.wrapDataFetcher is a helper to wrap data fetchers so that// CompletionStage is handled correctly along with POJOsDataFetcher<?> originalFetcher = env.getCodeRegistry()
.getDataFetcher(fieldsContainer, fieldDefinition);
DataFetcher<?> dataFetcher = DataFetcherFactories.wrapDataFetcher(originalFetcher,
((dataFetchingEnvironment, value) -> {
if (valueinstanceofLocalDateTimelocalDateTime
&& dataFetchingEnvironment.containsArgument(FORMAT)) {
StringdateTimePattern = dataFetchingEnvironment.getArgument(FORMAT);
DateTimeFormatterdateTimeFormatter = buildFormatter(dateTimePattern);
returndateTimeFormatter.format(localDateTime);
}
}
returnvalue;
}));
// This will extend the field by adding a new "format" argument to it for the date// formatting which allows clients to opt into.FieldCoordinatescoordinates = FieldCoordinates.coordinates(fieldsContainer,
fieldDefinition);
env.getCodeRegistry().dataFetcher(coordinates, dataFetcher);
returnfieldDefinition.transform(builder -> builder.argument(
GraphQLArgument.newArgument().name(FORMAT).type(Scalars.GraphQLString)));
}
privatestaticDateTimeFormatterbuildFormatter(Stringformat) {
returnDateTimeFormatter.ofPattern(format);
}
}
Wire the custom DateFormattingDirective alongside the standard setup of the graphql.java.extended.validation project:
Describe the bug
When wiring the default
graphql.java.extended.validation
setup with theRuntimeWiringConfigurer
provided by the newSpring for GraphQL
project, custom directives that are registered via the buildersdirective()
method don't seem to apply anymore.To Reproduce
graphql-java
DateFormattingDirective
:DateFormattingDirective
alongside the standard setup of thegraphql.java.extended.validation
project:DateFormattingDirective
disappear.Without
graphql.java.extended.validation
:With
graphql.java.extended.validation
:The text was updated successfully, but these errors were encountered: