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

Missing files when using go mod vendor #2081

Closed
lindlof opened this issue Apr 8, 2022 · 9 comments
Closed

Missing files when using go mod vendor #2081

lindlof opened this issue Apr 8, 2022 · 9 comments

Comments

@lindlof
Copy link

lindlof commented Apr 8, 2022

What happened?

When using go mod vendor to vendor dependencies some files are not included like everything in graphql/introspection directory.

This causes an error like:

reloading module info
reloading module info
reloading module info
merging type systems failed: unable to build object definition: unable to find type: github.com/99designs/gqlgen/graphql/introspection.EnumValue

Related to golang/go#26366

What did you expect?

All files required by api.Generate to be included in vendor/github.com/99designs/gqlgen directory

Minimal graphql.schema and models to reproduce

Any schema

versions

  • github.com/99designs/gqlgen v0.17.2
  • go version go1.17.8 darwin/arm64
  • go version go1.18 darwin/arm64
@darrensapalo
Copy link

darrensapalo commented Apr 11, 2022

Error message

$ go run github.com/99designs/gqlgen init
Creating gqlgen.yml
Creating graph/schema.graphqls
Creating server.go
Generating...
reloading module info
reloading module info
reloading module info
merging type systems failed: unable to build object definition: unable to find type: github.com/99designs/gqlgen/graphql/introspection.EnumValue
exit status 1

Objective

Generate auto-generated model files from a schema using go run github.com/99designs/gqlgen generate.

Diagnosis

  1. gqlgen depends on certain non-go related files (e.g. schema introspection files).
  2. go mod vendor unfortunately does not include those files it requires when using go mod vendor

Workaround

  1. Delete the vendorized dependencies vendor/github.com/99designs/gqlgen.
  2. git clone git@github.com:99designs/gqlgen.git into the directory vendor/github.com/99designs.
  3. Run go run github.com/99designs/gqlgen generate.

Caveats

Not sure yet what the impact will be, when you attempt to do go mod vendor ... will the missing files be deleted? I am not sure yet (still experimenting... might post results here later).

UPDATE: Running go mod vendor does not remove the additional files.

@shyyawn
Copy link

shyyawn commented May 6, 2022

Did this start happening with v0.17.2? I just upgraded my packages and this started happening.

@thesolution
Copy link

thesolution commented May 12, 2022

I had to go get github.com/hashicorp/golang-lru after executing the workaround.

versions

  • github.com/99designs/gqlgen v0.17.5
  • go version 1.18 darwin/amd64

@milesich
Copy link

You can also create a tools.go file and then go mod vendor would fetch the missing files.

//go:build tools
// +build tools

package tools

import (
	_ "github.com/99designs/gqlgen"
	_ "github.com/99designs/gqlgen/graphql/introspection"
)

@frederikhors
Copy link
Collaborator

@milesich answer is the way to go. It has been said many times now.

@thesolution
Copy link

I feel like the documentation needs an update if this is the preferred method. All projects at my job must be vendered. I was able to unblock myself using this issue.

@frederikhors
Copy link
Collaborator

@thesolution can you PR?

@thesolution
Copy link

@frederikhors I haven't before. Should I create an issue for a documentation update first or just put that info in the PR?

@frederikhors
Copy link
Collaborator

Create a PR. Someone on the team will consider whether to merge it.

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

6 participants