-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(grpc): linking multiple proto files with the same package name (#…
- Loading branch information
Showing
12 changed files
with
281 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,83 @@ | ||
# Grpc when multiple proto files have the same package name | ||
|
||
```protobuf @file:foo.proto | ||
syntax = "proto3"; | ||
import "google/protobuf/empty.proto"; | ||
package test; | ||
message Foo { | ||
string foo = 1; | ||
} | ||
service FooService { | ||
rpc GetFoo (google.protobuf.Empty) returns (Foo) {} | ||
} | ||
``` | ||
|
||
```protobuf @file:bar.proto | ||
syntax = "proto3"; | ||
package test; | ||
message Input { | ||
} | ||
message Bar { | ||
string bar = 1; | ||
} | ||
service BarService { | ||
rpc GetBar (Input) returns (Bar) {} | ||
} | ||
``` | ||
|
||
```graphql @server | ||
schema | ||
@server(port: 8000, graphiql: true) | ||
@upstream(baseURL: "http://localhost:50051") | ||
@link(src: "foo.proto", type: Protobuf) | ||
@link(src: "bar.proto", type: Protobuf) { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
foo: Foo! @grpc(method: "test.FooService.GetFoo") | ||
bar: Bar! @grpc(method: "test.BarService.GetBar") | ||
} | ||
|
||
type Foo { | ||
foo: String | ||
} | ||
|
||
type Bar { | ||
bar: String | ||
} | ||
``` | ||
|
||
```yml @mock | ||
- request: | ||
method: POST | ||
url: http://localhost:50051/test.FooService/GetFoo | ||
body: null | ||
response: | ||
status: 200 | ||
body: \0\0\0\0\n\n\x08test-foo | ||
|
||
- request: | ||
method: POST | ||
url: http://localhost:50051/test.BarService/GetBar | ||
body: null | ||
response: | ||
status: 200 | ||
body: \0\0\0\0\n\n\x08test-bar | ||
``` | ||
|
||
```yml @assert | ||
- method: POST | ||
url: http://localhost:8080/graphql | ||
body: | ||
query: query { foo { foo } bar { bar } } | ||
``` |
20 changes: 20 additions & 0 deletions
20
tests/snapshots/execution_spec__grpc-proto-with-same-package.md_assert_0.snap
This file contains 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,20 @@ | ||
--- | ||
source: tests/execution_spec.rs | ||
expression: response | ||
--- | ||
{ | ||
"status": 200, | ||
"headers": { | ||
"content-type": "application/json" | ||
}, | ||
"body": { | ||
"data": { | ||
"foo": { | ||
"foo": "test-foo" | ||
}, | ||
"bar": { | ||
"bar": "test-bar" | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
tests/snapshots/execution_spec__grpc-proto-with-same-package.md_client.snap
This file contains 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,32 @@ | ||
--- | ||
source: tests/execution_spec.rs | ||
expression: client | ||
--- | ||
type Bar { | ||
bar: String | ||
} | ||
|
||
scalar Date | ||
|
||
scalar Email | ||
|
||
scalar Empty | ||
|
||
type Foo { | ||
foo: String | ||
} | ||
|
||
scalar JSON | ||
|
||
scalar PhoneNumber | ||
|
||
type Query { | ||
bar: Bar! | ||
foo: Foo! | ||
} | ||
|
||
scalar Url | ||
|
||
schema { | ||
query: Query | ||
} |
Oops, something went wrong.
3450eff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running 30s test @ http://localhost:8000/graphql
4 threads and 100 connections
410563 requests in 30.01s, 2.06GB read
Requests/sec: 13682.36
Transfer/sec: 70.23MB