From 2b8f50b3b38b129f56e06c3dadccd0cb8667a741 Mon Sep 17 00:00:00 2001 From: ipfans <363344+ipfans@users.noreply.github.com> Date: Mon, 17 Jan 2022 01:00:12 +0800 Subject: [PATCH] Fix #1765: Sometimes module info not exists or not loaded. (#1767) * Fix #1765: Sometimes module info not exists or not loaded. * Remove failing test Signed-off-by: Steve Coffman Co-authored-by: Steve Coffman --- codegen/config/config.go | 2 +- codegen/config/config_test.go | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/codegen/config/config.go b/codegen/config/config.go index c93861346e9..77d92bdff5f 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -531,7 +531,7 @@ func (c *Config) autobind() error { } for i, p := range ps { - if p == nil || p.Module == nil { + if p == nil { return fmt.Errorf("unable to load %s - make sure you're using an import path to a package that exists", c.AutoBind[i]) } if t := p.Types.Scope().Lookup(t.Name); t != nil { diff --git a/codegen/config/config_test.go b/codegen/config/config_test.go index 29f37250a7d..7b52715861f 100644 --- a/codegen/config/config_test.go +++ b/codegen/config/config_test.go @@ -193,21 +193,4 @@ func TestAutobinding(t *testing.T) { require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/scalars/model.Banned", cfg.Models["Banned"].Model[0]) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.Message", cfg.Models["Message"].Model[0]) }) - - t.Run("with file path", func(t *testing.T) { - cfg := Config{ - Models: TypeMap{}, - AutoBind: []string{ - "../chat", - }, - Packages: &code.Packages{}, - } - - cfg.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "TestAutobinding.schema", Input: ` - scalar Banned - type Message { id: ID } - `}) - - require.EqualError(t, cfg.autobind(), "unable to load ../chat - make sure you're using an import path to a package that exists") - }) }