Skip to content

feat: pass graphQLContext to KotlinDataLoaderRegistryFactory #1785

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

Merged

Conversation

samuelAndalon
Copy link
Contributor

@samuelAndalon samuelAndalon commented Jun 1, 2023

📝 Description

passing graphQLContext instance from GraphQLRequestHandler to KotlinDataLoaderRegistryFactory.generate to allow DataLoaders to easily pass it as context of the BatchLoaderContext, and free up the context by key.

🔗 Related Issues

resolves #1752

@samuelAndalon samuelAndalon added the changes: major Changes require a major version label Jun 1, 2023
@samuelAndalon samuelAndalon added module: server Issue affects the server code module: executions issue affects the executions code and removed module: server Issue affects the server code labels Jun 1, 2023
@smyrick
Copy link
Contributor

smyrick commented Jun 1, 2023

You could take the Apollo Server approach and now that the graphql-java context is just a map, you could let library users save their own data loaders into the context and fetch them. Then you could just delete the KotlinDataLoader class altogether

@samuelAndalon
Copy link
Contributor Author

You could take the Apollo Server approach and now that the graphql-java context is just a map, you could let library users save their own data loaders into the context and fetch them. Then you could just delete the KotlinDataLoader class altogether

internally the DataLoaderRegistry is actually stored in the GraphQLContext, thats how data fetchers/resolvers can access to it through the DataFetchingEnvironment, KotlinDataLoader is a convenient way to allow users to register data loaders and let the server do the work of creating the registry and adding them to the context.

@dariuszkuc dariuszkuc merged commit c10e466 into ExpediaGroup:master Jun 1, 2023
@samuelAndalon samuelAndalon deleted the feat/dataloader-graphql-context branch June 1, 2023 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes: major Changes require a major version module: executions issue affects the executions code
Development

Successfully merging this pull request may close these issues.

Support per-request BatchLoaderContextProviders in data loaders and free up BatchLoaderEnvironment key contexts
4 participants