You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Followed the instructions in the documentation on Dataloaders and received an inscrutable error message:
go run github.com/vektah/dataloaden UserLoader string *github.com/org/project/pkg/graph/model.SiteInfo
unable to gofmt: /path/project/pkg/dataloader/userloader_gen.go:6:1: expected 'IDENT', found 'import'
exit status 2
What's worse, the code generator cleaned up after itself, giving little info about what might have gone wrong (userloader_gen.go does not exist).
What did you expect?
Documentation should contain correct steps to generate a data loader.
Recommended solution
Update the documentation to contain the missing steps described in vektah/dataloaden#35
I created a new file loaders.go containing only a package statement, and then the instructions worked as presented. There are a number of ways this could be addressed; a one-line fix is presented below:
go get github.com/vektah/dataloaden
mkdir dataloader
cd dataloader
echo 'package dataloader' > loaders.go
go run github.com/vektah/dataloaden UserLoader int *gqlgen-tutorials/dataloader/graph/model.User
Then, instruct users to populate the rest of loaders.go with contents similar to the example below after Dataloaden has generated the data loader.
The text was updated successfully, but these errors were encountered:
Also, tangentially related, to avoid a lint error in the example I replaced:
const loadersKey = "dataloaders"
With:
type key int
const (
loadersKey key = iota
)
Without this change, the linter reports:
SA1029: should not use built-in type string as key for value; define your own type to avoid collisions (staticcheck)
ctx := context.WithValue(r.Context(), loadersKey, &Loaders{
^
What happened?
Followed the instructions in the documentation on Dataloaders and received an inscrutable error message:
What's worse, the code generator cleaned up after itself, giving little info about what might have gone wrong (userloader_gen.go does not exist).
What did you expect?
Documentation should contain correct steps to generate a data loader.
Recommended solution
Update the documentation to contain the missing steps described in vektah/dataloaden#35
I created a new file
loaders.go
containing only apackage
statement, and then the instructions worked as presented. There are a number of ways this could be addressed; a one-line fix is presented below:Then, instruct users to populate the rest of loaders.go with contents similar to the example below after Dataloaden has generated the data loader.
The text was updated successfully, but these errors were encountered: