INNER CODE UNIT · Go

new_graphql_resolver_

ysugimoto/grpc-graphql-gateway · protoc-gen-graphql/template.go:221

func new_graphql_resolver_{{ $service.Name }}(conn *grpc.ClientConn) *graphql__resolver_{{ $service.Name }} {
	return &graphql__resolver_{{ .Name }}{
		conn: conn,
		host: "{{ if .Host }}{{ .Host }}{{ else }}localhost:50051{{ end }}",
		dialOptions: []grpc.DialOption{
		{{- if .Insecure }}
			grpc.WithTransportCredentials(insecure.NewCredentials()),
		{{- end }}
		},
	}
}

// CreateConnection() returns grpc connection which user specified or newly connected and closing function
func (x *graphql__resolver_{{ $service.Name }}) CreateConnection(ctx context.Context) (*grpc.ClientConn, func(), error) {
	// If x.conn is not nil, user injected their own connection
	if x.conn != nil {
		return x.conn, func() {}, nil
	}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…