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

The way BatchLoaderHandlerMethod resolve argument #297

Closed
dugenkui03 opened this issue Feb 20, 2022 · 2 comments
Closed

The way BatchLoaderHandlerMethod resolve argument #297

dugenkui03 opened this issue Feb 20, 2022 · 2 comments

Comments

@dugenkui03
Copy link
Contributor

dugenkui03 commented Feb 20, 2022

In #232 , I suggested that @BatchMapping should support @Argument, because user will define arguments on field, no matter whether the field is fetched by DataLoader or 'n+1' way. Furthermore, user will always want to get information about field, such as field definition or directives info.

Hence, I think BatchLoaderHandlerMethod should support custom argument resolve strategy which resolving method parameters into argument values, like #295 . BatchMappingDataFetcher should use dataLoader.load(env.getSource(), env);(code like below), and argument resolve strategy and batch handler method will get all the information about the fetched field.

	static class BatchMappingDataFetcher implements DataFetcher<Object> {

                ......

		@Override
		public Object get(DataFetchingEnvironment env) {
			DataLoader<?, ?> dataLoader = env.getDataLoaderRegistry().getDataLoader(this.dataLoaderKey);
			if (dataLoader == null) {
				throw new IllegalStateException("No DataLoader for key '" + this.dataLoaderKey + "'");
			}
                         // pass DataFetchingEnvironment to DataLoader and other component
			return dataLoader.load(env.getSource(), env);
		}
	}
@dugenkui03
Copy link
Contributor Author

#298 This pr support for BatchHandlerMethodArgumentResolver. Maybe a later pr could custom BatchHandlerMethodArgumentResolver (similar like #295). Is this a right way

@dugenkui03
Copy link
Contributor Author

Details in #298

@rstoyanchev rstoyanchev removed the status: waiting-for-triage An issue we've not yet triaged label Nov 17, 2022
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

No branches or pull requests

3 participants