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

Upgrade to github.com/graph-gophers/dataloader/v7 #46

Open
felixhromadko opened this issue Jan 30, 2024 · 0 comments
Open

Upgrade to github.com/graph-gophers/dataloader/v7 #46

felixhromadko opened this issue Jan 30, 2024 · 0 comments
Labels

Comments

@felixhromadko
Copy link
Collaborator

The v7 of the library allows using generics in the key / result. We should consider upgrading to it.

Definition in v5 (current):

	CompetenceLoader  *dataloader.Loader

Definition in v7:

	CompetenceLoader  *dataloader.Loader[string, db.Competence]

This would allow us to remove these functions, especially the somewhat dangerous casting .([]*db.Competence), because the dataloader -> thunk() is already returning the correct type.

func GetCompetenceParents(ctx context.Context, competenceID string, currentUser *middleware.UserContext) ([]*db.Competence, error) {
	loaders := For(ctx)
	thunk := loaders.CompetenceLoader.Load(ctx, dataloader.StringKey(competenceID))
	result, err := thunk()
	if err != nil {
		return nil, err
	}
	return result.([]*db.Competence), nil
}
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

2 participants