Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation includes deprecated code #783

Open
ataylormays-duetto opened this issue Apr 25, 2024 · 0 comments
Open

Documentation includes deprecated code #783

ataylormays-duetto opened this issue Apr 25, 2024 · 0 comments
Labels

Comments

@ataylormays-duetto
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant