Gqlgen: validation fails with mono-repository structure

Created on 12 Mar 2020  路  2Comments  路  Source: 99designs/gqlgen

What happened?

We currently have a mono repo that contains multiple go projects. For example, we have the following example projects:

  • https://github.com/<company>/golang/<project1>
  • https://github.com/<company>/golang/<project2>

One of the projects is using GRPC + Firestore + GQLGen together. The module namespace for this project is github.com/<company>/<project1> (notice the golang segment is not there).

We are trying to re-use model structures that were generated as part of GRPC in the pbchat package.

We've updated the gqlgen.yml file to add our models as follows:

  Identity:
    model: github.com/<company>/<project1>/pbchat.Identity
  Conversation:
    model: github.com/<company>/<project1>/pbchat.Conversation
  Message:
    model: github.com/<company>/<project1>/pbchat.Message

We also updated the model section of gqlgen.yml as follows:

model:
  filename: graph/model/models_gen.go
  package: pbchat

If we run go generate ./... with skip_validation=false, we get the following error:

% go generate ./...
validation failed: packages.Load: -: cannot find module providing package github.com/<company>/<project1>/graph/model: module github.com/fitmo/chat-service/graph/model: git ls-remote -q origin in ~/projects/golang/pkg/mod/cache/vcs/3c5e1679b6aa1584ce354a41e10acb6faf0722ec041bd6685f2ea89aca0835e0: exit status 128:
    remote: Repository not found.
    fatal: repository 'https://github.com/<company>/<project1>/' not found
exit status 1
graph/resolver.go:3: running "go": exit status 1

If we turn validation of by setting skip_validation to true then we are able to generate and run the project successfully

What did you expect?

I would have expected the generator to respect the project module namespace and validate locally instead of on the remote server

Minimal graphql.schema and models to reproduce

Not sure this is required as the issue has to do with non-generated model structures and the module namespace not matching the remote repository

versions

  • gqlgen version?
    v0.11.2
  • go version?
    go version go1.14 darwin/amd64
stale

Most helpful comment

Did you ever find a solution to this @ikbenben?

All 2 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Did you ever find a solution to this @ikbenben?

Was this page helpful?
0 / 5 - 0 ratings