graphql-java-kickstart/graphql-java-tools

Documentation includes deprecated code

Opened this issue · 0 comments

Description

https://www.graphql-java-kickstart.com/tools/directives/ includes the following code:

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.