gqlgen: reloading module info generating core failed:

What happened?

gqlgen --config ./gqlgen.yml

reloading module info
generating core failed: unable to load github.com/kokutas/graphic/graph/model - make sure you're using an import path to a package that exists

gqlgen.yml

# Where are all the schema files located? globs are supported eg  src/**/*.graphqls
schema:
  - graph/*.graphqls

# Where should the generated server code go?
exec:
  filename: graph/generated/generated.go
  package: generated

# Uncomment to enable federation
# federation:
#   filename: graph/generated/federation.go
#   package: generated

# Where should any generated models go?
model:
  filename: graph/model/models_gen.go
  package: model

# Where should the resolver implementations go?
resolver:
  layout: follow-schema
  dir: graph
  package: graph

# Optional: turn on use `gqlgen:"fieldName"` tags in your models
# struct_tag: json

# Optional: turn on to use []Thing instead of []*Thing
# omit_slice_element_pointers: false

# Optional: set to speed up generation time by not performing a final validation pass.
# skip_validation: true

# gqlgen will search for any type names in the schema in these go packages
# if they match it will use them, otherwise it will generate them.
autobind:
  - "github.com/kokutas/graphic/graph/model"

# This section declares type mapping between the GraphQL and go type systems
#
# The first line in each type will be used as defaults for resolver arguments and
# modelgen, the others will be allowed when binding to fields. Configure them to
# your liking
models:
  ID:
    model:
      - github.com/99designs/gqlgen/graphql.ID
      - github.com/99designs/gqlgen/graphql.Int
      - github.com/99designs/gqlgen/graphql.Int64
      - github.com/99designs/gqlgen/graphql.Int32
  Int:
    model:
      - github.com/99designs/gqlgen/graphql.Int
      - github.com/99designs/gqlgen/graphql.Int64
      - github.com/99designs/gqlgen/graphql.Int32

schema.graphs

# GraphQL schema example
#
# https://gqlgen.com/getting-started/

type Todo {
  id: ID!
  text: String!
  done: Boolean!
  user: User!
}

type User {
  id: ID!
  name: String!
}

type Query {
  todos: [Todo!]!
}

input NewTodo {
  text: String!
  userId: String!
}

type Mutation {
  createTodo(input: NewTodo!): Todo!
}

What did you expect?

Minimal graphql.schema and models to reproduce

versions

  • gqlgen version?
  • v0.14.0-dev
  • go version?
  • go version go1.16.10 darwin/amd64
  • dep or go modules?
  • github.com/99designs/gqlgen v0.16.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 21 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@mtibben I understand what you want saying. actually we can not reproduce this issue at master branch following this.

I’m also thinking we can just revert https://github.com/99designs/gqlgen/commit/c99fde1e28aec9342bf212ff5c2744ad2c781acf

When following the directions, users got an error because gqlgen cannot autobind to an empty models directory. The workaround was to either comment out autobind in the config or put an empty model file in there. We did both, which is like wearing both a belt and braces (suspenders / サスペンダ ?). Reverting the prtinf is fine as long as the autobind is still commented out, or we avoid the error completely in this case.

I would be very excited to get a PR that would allow us to NOT throw an error in this specific case (just haven’t generated yet) but DO throw an error when we after we generate the thing we are trying to autobind is still not there. That would help a lot of people getting started to avoid a confusing situation.

Just make a PR for the https://github.com/99designs/gqlgen/blob/master/README.md and I will take care of the rest.

@ubiuser yes, it is. I just hit this issue as well with v0.16.0 … if I switch to v0.15.1 everthing works ok:

...
go mod tidy
go get -d github.com/99designs/gqlgen@v0.15.1
go run github.com/99designs/gqlgen init
go run github.com/99designs/gqlgen generate