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

Generate groups and reorders imports incorrectly #3586

Open
mdakovac opened this issue Mar 11, 2025 · 3 comments
Open

Generate groups and reorders imports incorrectly #3586

mdakovac opened this issue Mar 11, 2025 · 3 comments

Comments

@mdakovac
Copy link

mdakovac commented Mar 11, 2025

gqlgen version: v0.17.66
go version: 1.23.3

full repro: https://github.com/mdakovac/gqlgen-import-sorting/tree/main

Go lets you group imports by separating them with a newline, however when you run the generate command, this grouping is broken.

import statement before generate in graph/schema.resolvers.go file

import (
	"context"
	"fmt"

	"github.com/rs/zerolog"

	"github.com/example/gqlgen-import-sorting/graph/model"
	"github.com/spf13/viper"
)

after generate

import (
	"context"
	"fmt"

	"github.com/example/gqlgen-import-sorting/graph/model"
	"github.com/rs/zerolog"
	"github.com/spf13/viper"
)
@StevenACoffman
Copy link
Collaborator

Which file is getting altered in this way?

@mdakovac
Copy link
Author

graph/schema.resolvers.go is the file, added to description

@StevenACoffman
Copy link
Collaborator

StevenACoffman commented Mar 13, 2025

Thanks! That is irksome, and I'm not sure why that is happening. If you care to make a PR to fix it, I would appreciate it. I would have thought this would have been the result:

import (
	"context"
	"fmt"

	"github.com/rs/zerolog"
	"github.com/spf13/viper"

	"github.com/example/gqlgen-import-sorting/graph/model"
)

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

2 participants