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

generating core failed: unable to load github.com/kelvin/gqlgen-todos/graph/model - make sure you're using an import path to a package that exists #1765

Closed
kelvinink opened this issue Jan 15, 2022 · 9 comments · Fixed by #1767

Comments

@kelvinink
Copy link

What happened?

I encountered an issue when following the init instruction to init my example gqlgen project. When I ran go run github.com/99designs/gqlgen init it output an error message:

Creating gqlgen.yml
Creating graph/schema.graphqls
Creating server.go
Generating...
generating core failed: unable to load github.com/kelvin/gqlgen-todos/graph/model - make sure you're using an import path to a package that exists

Exec "go run ./server.go" to start GraphQL server

What did you expect?

I expect it to generate the models, resolvers. But it didn't.

Minimal graphql.schema and models to reproduce

versions

  • gqlgen version?
  • v0.15.0
  • go version?
  • go1.16.3
  • dep or go modules?
@yash492
Copy link

yash492 commented Jan 15, 2022

I'm having the same issue. I think there's something broken in new release (v.15.0).
Try using this version.
go get github.com/99designs/gqlgen@v0.14.0

Worked for me.

@ManWithA1000Names
Copy link

If you want to use v0.15.0, you can for now comment out the autobind option in the gqlgen.yml and it should work fine:

# ...
resolver:
# ...
  autobind:
    - "your module name/graph/model"

||
\/

# ...
resolver:
# ...
#  autobind:
#    - "your module name/graph/model"

@ipfans
Copy link
Contributor

ipfans commented Jan 16, 2022

Yes, You have some workarounds for this(choose the one you like):

  1. comment the autobind section so you will not auto load the empty dir.
  2. Touch a new empty go file in graph/model dir:
echo "package model" > graph/model/_tmp_gqlgen_init.go

StevenACoffman added a commit that referenced this issue Jan 16, 2022
* Fix #1765: Sometimes module info not exists or not loaded.

* Remove failing test

Signed-off-by: Steve Coffman <steve@khanacademy.org>

Co-authored-by: Steve Coffman <steve@khanacademy.org>
@StevenACoffman
Copy link
Collaborator

StevenACoffman commented Jan 16, 2022

Sorry folks! I would appreciate more code coverage around this area, so PRs are welcome.

@ipfans ipfans mentioned this issue Jan 17, 2022
2 tasks
StevenACoffman pushed a commit that referenced this issue Jan 19, 2022
* Improve test case for #1765

* Imporve test cases for init and generate
@domgolonka
Copy link

Seems the issue persists, but when I am commenting out autobind, the generate fails to find my custom models:

modelgen: required package was not loaded: gitlab.com/domgolonka/api/scalars.UUIDmake: *** [generate] Error 1

@ipfans
Copy link
Contributor

ipfans commented Jan 25, 2022

@domgolonka Hi, have you tried the master branch yet?

@zachsmith1
Copy link
Contributor

zachsmith1 commented Feb 6, 2022

@ipfans and @StevenACoffman this is still an issue on 0.16 and on master. I was simply trying out the demo here and it wouldn't work.

Note: there may be different issues. I want to point out that the autogenerated config file by init adds a directory to the autobind section. This makes an immediate call to generate (with no changes) to fail.

Go version: 1.17

@iamjenechka
Copy link

what if I use a private code repo?

@StevenACoffman
Copy link
Collaborator

StevenACoffman commented Feb 15, 2022

@honeywild should be fine!

Also, I think the documentation has been corrected now to comment out the autobind until you actually have files in there to autobind to @zachsmith1

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

Successfully merging a pull request may close this issue.

8 participants