-
Notifications
You must be signed in to change notification settings - Fork 233
feat(router): add ConnectRPC protocol support for gRPC subgraphs #2665
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
Closed
fengyuwusong
wants to merge
4
commits into
wundergraph:main
from
fengyuwusong:feat/connectrpc-router-integration
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a80ccc2
feat(router): add ConnectRPC protocol support for gRPC subgraphs
fengyuwusong 70e804e
fix(router): wire grpcProtocolConfig and validate ConnectRPC config
fengyuwusong ad6dbc1
fix(router): add TLS-only subgraph clients and remove local replace d…
fengyuwusong 63ee05d
fix(router): add TLS-only subgraph clients and use fork for graphql-g…
fengyuwusong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package grpcprotocol | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/wundergraph/cosmo/router/pkg/config" | ||
| ) | ||
|
|
||
| const ( | ||
| ProtocolGRPC = "grpc" | ||
| ProtocolConnectRPC = "connectrpc" | ||
|
|
||
| EncodingProto = "proto" | ||
| EncodingJSON = "json" | ||
| ) | ||
|
|
||
| // Validate checks that all config values in a GRPCProtocolConfig are valid. | ||
| func Validate(cfg *config.GRPCProtocolConfig) error { | ||
| if cfg == nil { | ||
| return nil | ||
| } | ||
| if cfg.Default != "" && cfg.Default != ProtocolGRPC && cfg.Default != ProtocolConnectRPC { | ||
| return fmt.Errorf("grpc_protocol.default: invalid value %q, must be %q or %q", cfg.Default, ProtocolGRPC, ProtocolConnectRPC) | ||
| } | ||
| if cfg.DefaultEncoding != "" && cfg.DefaultEncoding != EncodingProto && cfg.DefaultEncoding != EncodingJSON { | ||
| return fmt.Errorf("grpc_protocol.default_encoding: invalid value %q, must be %q or %q", cfg.DefaultEncoding, EncodingProto, EncodingJSON) | ||
| } | ||
| for name, sg := range cfg.Subgraphs { | ||
| if sg.Protocol != "" && sg.Protocol != ProtocolGRPC && sg.Protocol != ProtocolConnectRPC { | ||
| return fmt.Errorf("grpc_protocol.subgraphs.%s.protocol: invalid value %q", name, sg.Protocol) | ||
| } | ||
| if sg.Encoding != "" && sg.Encoding != EncodingProto && sg.Encoding != EncodingJSON { | ||
| return fmt.Errorf("grpc_protocol.subgraphs.%s.encoding: invalid value %q", name, sg.Encoding) | ||
| } | ||
| } | ||
| return nil | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| // ResolveProtocol returns the effective protocol for a subgraph. | ||
| func ResolveProtocol(cfg *config.GRPCProtocolConfig, subgraphName string) string { | ||
| if cfg == nil { | ||
| return ProtocolGRPC | ||
| } | ||
| if sg, ok := cfg.Subgraphs[subgraphName]; ok && sg.Protocol != "" { | ||
| return sg.Protocol | ||
| } | ||
| if cfg.Default != "" { | ||
| return cfg.Default | ||
| } | ||
| return ProtocolGRPC | ||
| } | ||
|
|
||
| // ResolveEncoding returns the effective encoding for a subgraph. | ||
| func ResolveEncoding(cfg *config.GRPCProtocolConfig, subgraphName string) string { | ||
| if cfg == nil { | ||
| return EncodingProto | ||
| } | ||
| if sg, ok := cfg.Subgraphs[subgraphName]; ok && sg.Encoding != "" { | ||
| return sg.Encoding | ||
| } | ||
| if cfg.DefaultEncoding != "" { | ||
| return cfg.DefaultEncoding | ||
| } | ||
| return EncodingProto | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.