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
public class UppercaseDirective implements SchemaDirectiveWiring {
@Override
public GraphQLFieldDefinition onField(SchemaDirectiveWiringEnvironment<GraphQLFieldDefinition> env) {
GraphQLFieldDefinition field = env.getElement();
GraphQLFieldsContainer parentType = env.getFieldsContainer();
// build a data fetcher that transforms the given value to uppercase
DataFetcher originalFetcher = env.getCodeRegistry().getDataFetcher(parentType, field);
DataFetcher dataFetcher =
DataFetcherFactories.wrapDataFetcher(
originalFetcher,
((dataFetchingEnvironment, value) -> {
if (value instanceof String) {
return ((String) value).toUpperCase();
}
return value;
}));
// now change the field definition to use the new uppercase data fetcher
env.getCodeRegistry().dataFetcher(parentType, field, dataFetcher);
return field;
}
}
However, DataFetcher originalFetcher = env.getCodeRegistry().getDataFetcher(parentType, field); is a deprecated method, which has now been removed in the latest v22 of graphql-java: https://github.com/graphql-java/graphql-java/pull/3514/files.
Expected behavior
The documentation is updated to show how to implement directives w/ the latest version of graphql-java.
Actual behavior
The documentation uses outdated code that is incompatible with the latest version of graphql-java.
The text was updated successfully, but these errors were encountered:
Description
https://www.graphql-java-kickstart.com/tools/directives/ includes the following code:
However,
DataFetcher originalFetcher = env.getCodeRegistry().getDataFetcher(parentType, field);
is a deprecated method, which has now been removed in the latest v22 of graphql-java: https://github.com/graphql-java/graphql-java/pull/3514/files.Expected behavior
The documentation is updated to show how to implement directives w/ the latest version of graphql-java.
Actual behavior
The documentation uses outdated code that is incompatible with the latest version of graphql-java.
The text was updated successfully, but these errors were encountered: