Skip to content

Commit

Permalink
Merge pull request #66 from envelope-org/fix/issue-63
Browse files Browse the repository at this point in the history
fixed support for a custom-defined package names via option go_package
  • Loading branch information
ysugimoto authored May 11, 2024
2 parents 156a30b + 5513161 commit 6818d9f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions protoc-gen-graphql/spec/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,13 @@ func (f *File) messagesRecursive(d *descriptor.DescriptorProto, prefix []string,
return messages
}

// Package is a package name retrieved from protobuf's package keyword
func (f *File) Package() string {
return f.descriptor.GetPackage()
}

// GoPackage will search for an option named go_package and, if found, returns it.
// Otherwise, it calls Package
func (f *File) GoPackage() string {
var pkgName string
if opt := f.descriptor.GetOptions(); opt == nil {
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-graphql/spec/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewPackage(g PackageGetter) *Package {
p.FileName = filepath.Base(p.GeneratedFilenamePrefix)

if pkg := g.GoPackage(); pkg != "" {
// Support custom package definitions like example.com/path/to/package:packageName
// Support custom package definitions like example.com/path/to/package;packageName
if index := strings.Index(pkg, ";"); index > -1 {
p.Name = pkg[index+1:]
p.Path = pkg[0:index]
Expand Down
12 changes: 6 additions & 6 deletions protoc-gen-graphql/template.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6818d9f

Please sign in to comment.