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

Add support for defining a default DataFetcherFactory via autoconfig #979

Merged
merged 3 commits into from Apr 13, 2022

Conversation

jord1e
Copy link
Contributor

@jord1e jord1e commented Apr 12, 2022

Pull request checklist

  • Please read our contributor guide
  • Consider creating a discussion on the discussion forum
    first
  • Make sure the PR doesn't introduce backward compatibility issues
  • Make sure to have sufficient test cases

Pull Request type

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Changes in this PR

By default a PropertyDataFetcher will be configured when no data fetcher has been specified. You can provide a custom DataFetcherFactory to GraphQLCodeRegistry which gives you the ability to change this default behaviour.

I have been doing some work on dynamically generating the PropertyDataFetcher logic directly (instead of PropertyDataFetcher's reflection behaviour) in a class using the ASM bytecode library: https://github.com/jord1e/graphql-java-asm-datafetcher

By simply providing a AsmDataFetcherFactory the required classes get generated lazily, increasing performance by 10x+, matching handwritten data fetchers, in my initial testing (I will further work on this proof of concept to make it better match the default PropertyDataFetcher i.e. add generic Map<Object, Object> support).

This is not the only use-case of course but the ability to define a DataFetcherFactory as a bean is a low maintaince thing we can do.

Alternatives considered

N/A, Spring for GraphQL has a way to customize the GraphQL instance, I don't think DGS has this.

@berngp berngp force-pushed the default-datafetcher-factory-bean branch from 2de2a6d to f64d21c Compare April 13, 2022 02:56
Copy link
Contributor

@berngp berngp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, thanks for the pr @jord1e

@berngp berngp merged commit ff7c5c3 into Netflix:master Apr 13, 2022
@jord1e jord1e deleted the default-datafetcher-factory-bean branch April 13, 2022 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants