add graphql

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-06-11 20:45:45 +03:00
parent 55fa1ee403
commit 6d17a74ffb
16 changed files with 8494 additions and 48 deletions

30
graphql/goreference.go Normal file
View File

@@ -0,0 +1,30 @@
package generator
import (
"google.golang.org/protobuf/compiler/protogen"
)
type GoRef interface {
FindGoField(field string) *protogen.Field
}
func NewGoRef(p *protogen.Plugin) (GoRef, error) {
return goRef{p}, nil
}
type goRef struct {
*protogen.Plugin
}
func (g goRef) FindGoField(field string) *protogen.Field {
for _, file := range g.Files {
for _, msg := range file.Messages {
for _, f := range msg.Fields {
if string(f.Desc.FullName()) == field {
return f
}
}
}
}
return nil
}