99designs / 99designs/gqlgen

ResolverImplementer plugins: AutoBind packages not importing custom packages in resolver files

Aberta
#2,680 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Go
Estrelas
10.8k
Forks
1.3k
Merge médio
2d 36min
PRs com merge (30d)
26

Descrição

### What happened?
When creating a new plugin with the ResolverImplementer interface to customize resolver implementation functions, not all custom packages are imported automatically, even if they have been added as AutoBind packages.

### What did you expect?
To enhance the functionality of the Plugin ResolverImplementer, it would be beneficial to add the ability to include imports or ensure that the AutoBind packages are respected. This would automate the process of importing custom packages and ensure that they are properly included in the resolver implementation.

### Minimal graphql.schema and models to reproduce

In my specific case, it seems that the gqlgen plugin is not automatically importing the "json" package.

```go
func (m *MyPlugin) Implement(field *codegen.Field) string {
if field.Type.String() == "CustomQuery" {
return `
someObj := SomeType{}
_ := json.Unmarshal(someJson, &someObj)
return someObj, nil
`
}
return fmt.Sprintf("panic(fmt.Errorf(\"not implemented: %v - %v\"))", field.GoFieldName, field.Name)
}
```
### versions
- `go run github.com/99designs/gqlgen version` v0.17.33
- `go version` go1.20.1 darwin/arm64

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.