Skip to content

Commit

Permalink
chore: add package name to news.proto (tailcallhq#1087)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddOnTop authored Feb 3, 2024
1 parent 6256d6f commit f3cf2f1
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 29 deletions.
6 changes: 3 additions & 3 deletions examples/grpc.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ schema
}

type Query {
news: NewsData! @grpc(service: "NewsService", method: "GetAllNews", protoPath: "src/grpc/tests/news.proto")
news: NewsData! @grpc(service: "news.NewsService", method: "GetAllNews", protoPath: "src/grpc/tests/news.proto")
newsById(news: NewsInput!): News!
@grpc(service: "NewsService", method: "GetNews", body: "{{args.news}}", protoPath: "src/grpc/tests/news.proto")
@grpc(service: "news.NewsService", method: "GetNews", body: "{{args.news}}", protoPath: "src/grpc/tests/news.proto")
newsByIdBatch(news: NewsInput!): News!
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "GetMultipleNews"
body: "{{args.news}}"
protoPath: "src/grpc/tests/news.proto"
Expand Down
4 changes: 2 additions & 2 deletions src/grpc/protobuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ mod tests {
#[tokio::test]
async fn news_proto_file() -> Result<()> {
let file = ProtobufSet::from_proto_file(&get_proto_file("news.proto").await?)?;
let service = file.find_service("NewsService")?;
let service = file.find_service("news.NewsService")?;
let operation = service.find_operation("GetNews")?;

let input = operation.convert_input(r#"{ "id": 1 }"#)?;
Expand All @@ -357,7 +357,7 @@ mod tests {
#[tokio::test]
async fn news_proto_file_multiple_messages() -> Result<()> {
let file = ProtobufSet::from_proto_file(&get_proto_file("news.proto").await?)?;
let service = file.find_service("NewsService")?;
let service = file.find_service("news.NewsService")?;
let multiple_operation = service.find_operation("GetMultipleNews")?;

let child_messages = vec![r#"{ "id": 3 }"#, r#"{ "id": 5 }"#, r#"{ "id": 1 }"#];
Expand Down
4 changes: 3 additions & 1 deletion src/grpc/tests/news.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

import "google/protobuf/empty.proto";

package news;

message News {
int32 id = 1;
string title = 2;
Expand All @@ -27,5 +29,5 @@ message MultipleNewsId {
}

message NewsList {
repeated News news = 1;
repeated News news = 1;
}
4 changes: 3 additions & 1 deletion tests/graphql/errors/proto/news.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

import "google/protobuf/empty.proto";

package news;

message News {
int32 id = 1;
string title = 2;
Expand All @@ -28,4 +30,4 @@ message MultipleNewsId {

message NewsList {
repeated News news = 1;
}
}
2 changes: 1 addition & 1 deletion tests/graphql/errors/test-grpc-group-by.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ schema @server(port: 8000, graphiql: true) @upstream(httpCache: true, batch: {de
type Query {
newsById(news: NewsInput!): News!
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "GetMultipleNews"
baseURL: "http://localhost:50051"
body: "{{args.news}}"
Expand Down
2 changes: 1 addition & 1 deletion tests/graphql/errors/test-grpc-missing-fields.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ schema {
type Query {
news: NewsData!
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "GetAllNews"
baseURL: "http://localhost:4000"
protoPath: "tests/graphql/errors/proto/news.proto"
Expand Down
4 changes: 2 additions & 2 deletions tests/graphql/errors/test-grpc-nested-data.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ schema @server(port: 8000, graphiql: true) @upstream(httpCache: true, batch: {de
type Query {
news: NewsData!
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "GetAllNews"
baseURL: "http://localhost:50051"
protoPath: "src/grpc/tests/news.proto"
)
newsById(news: NewsInput!): [News]!
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "GetNews"
baseURL: "http://localhost:50051"
body: "{{args.news}}"
Expand Down
2 changes: 1 addition & 1 deletion tests/graphql/errors/test-grpc-nested-optional.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ schema {
type Query {
news: NewsData!
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "GetAllNews"
baseURL: "http://localhost:4000"
protoPath: "tests/graphql/errors/proto/news.proto"
Expand Down
2 changes: 1 addition & 1 deletion tests/graphql/errors/test-grpc-optional.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ schema {
type Query {
news: NewsData
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "GetAllNews"
baseURL: "http://localhost:4000"
protoPath: "tests/graphql/errors/proto/news.proto"
Expand Down
2 changes: 1 addition & 1 deletion tests/graphql/errors/test-grpc-proto-path.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ schema {
type Query {
news: NewsData
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "GetAllNews"
baseURL: "http://localhost:4000"
protoPath: "tailcall/src/grpcnews.proto"
Expand Down
2 changes: 1 addition & 1 deletion tests/graphql/errors/test-grpc-service-method.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ schema {
type Query {
news: NewsData
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "X"
baseURL: "http://localhost:4000"
protoPath: "tests/graphql/errors/proto/news.proto"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,23 @@ type Query {
@grpc(
method: "GetAllNews"
protoPath: "src/grpc/tests/news.proto"
service: "NewsService"
service: "news.NewsService"
headers: [{key: "id", value: "{{args.id}}"}]
)
newsGrpcUrl: NewsData!
@grpc(method: "GetAllNews", protoPath: "src/grpc/tests/news.proto", service: "NewsService", baseURL: "{{args.url}}")
@grpc(
method: "GetAllNews"
protoPath: "src/grpc/tests/news.proto"
service: "news.NewsService"
baseURL: "{{args.url}}"
)
newsGrpcBody: NewsData!
@grpc(method: "GetAllNews", protoPath: "src/grpc/tests/news.proto", service: "NewsService", body: "{{args.id}}")
@grpc(
method: "GetAllNews"
protoPath: "src/grpc/tests/news.proto"
service: "news.NewsService"
body: "{{args.id}}"
)
}

type User {
Expand Down
2 changes: 1 addition & 1 deletion tests/graphql/test-expr-success.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Post {
type Query {
cond: Post @expr(body: {if: {cond: {const: true}, else: {http: {path: "/posts/1"}}, then: {http: {path: "/posts/2"}}}})
greeting: String @expr(body: {const: "hello from server"})
news(news: NewsInput!): News! @expr(body: {grpc: {body: "{{args.news}}", groupBy: ["news", "id"], method: "GetMultipleNews", protoPath: "src/grpc/tests/news.proto", service: "NewsService"}})
news(news: NewsInput!): News! @expr(body: {grpc: {body: "{{args.news}}", groupBy: ["news", "id"], method: "GetMultipleNews", protoPath: "src/grpc/tests/news.proto", service: "news.NewsService"}})
post(id: Int!): Post @expr(body: {http: {baseURL: "http://jsonplacheholder.typicode.com", path: "/posts/{{args.id}}"}})
}

Expand Down
6 changes: 3 additions & 3 deletions tests/graphql/test-grpc.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ type NewsData {
}

type Query {
news: NewsData! @grpc(method: "GetAllNews", protoPath: "src/grpc/tests/news.proto", service: "NewsService")
newsById(news: NewsInput!): News! @grpc(body: "{{args.news}}", method: "GetNews", protoPath: "src/grpc/tests/news.proto", service: "NewsService")
newsByIdBatch(news: NewsInput!): News! @grpc(body: "{{args.news}}", groupBy: ["news", "id"], method: "GetMultipleNews", protoPath: "src/grpc/tests/news.proto", service: "NewsService")
news: NewsData! @grpc(method: "GetAllNews", protoPath: "src/grpc/tests/news.proto", service: "news.NewsService")
newsById(news: NewsInput!): News! @grpc(body: "{{args.news}}", method: "GetNews", protoPath: "src/grpc/tests/news.proto", service: "news.NewsService")
newsByIdBatch(news: NewsInput!): News! @grpc(body: "{{args.news}}", groupBy: ["news", "id"], method: "GetMultipleNews", protoPath: "src/grpc/tests/news.proto", service: "news.NewsService")
}

#> client-sdl
Expand Down
4 changes: 2 additions & 2 deletions tests/http/config/grpc-batch.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ schema @server(port: 8000, graphiql: true) @upstream(httpCache: true, batch: {de
type Query {
news: NewsData!
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "GetAllNews"
baseURL: "http://localhost:50051"
protoPath: "src/grpc/tests/news.proto"
)
newsById(news: NewsInput!): News!
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "GetMultipleNews"
baseURL: "http://localhost:50051"
body: "{{args.news}}"
Expand Down
4 changes: 2 additions & 2 deletions tests/http/config/grpc.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ schema @server(port: 8000, graphiql: true) @upstream(httpCache: true, batch: {de
type Query {
news: NewsData!
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "GetAllNews"
baseURL: "http://localhost:50051"
protoPath: "src/grpc/tests/news.proto"
)
newsById(news: NewsInput!): News!
@grpc(
service: "NewsService"
service: "news.NewsService"
method: "GetNews"
baseURL: "http://localhost:50051"
body: "{{args.news}}"
Expand Down
4 changes: 2 additions & 2 deletions tests/http/grpc-batch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ config: !file tests/http/config/grpc-batch.graphql
name: Grpc datasource with batching
mock:
- request:
url: http://localhost:50051/NewsService/GetMultipleNews
url: http://localhost:50051/news.NewsService/GetMultipleNews
method: POST
body: \0\0\0\0\n\x02\x08\x02\n\x02\x08\x03
response:
body: \0\0\0\0t\n#\x08\x02\x12\x06Note 2\x1a\tContent 2\"\x0cPost image 2\n#\x08\x03\x12\x06Note 3\x1a\tContent 3\"\x0cPost image 3
- request:
url: http://localhost:50051/NewsService/GetMultipleNews
url: http://localhost:50051/news.NewsService/GetMultipleNews
method: POST
body: \0\0\0\0\n\x02\x08\x03\n\x02\x08\x02
response:
Expand Down
2 changes: 1 addition & 1 deletion tests/http/grpc-simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ config: !file tests/http/config/grpc.graphql
name: Grpc datasource
mock:
- request:
url: http://localhost:50051/NewsService/GetAllNews
url: http://localhost:50051/news.NewsService/GetAllNews
method: POST
response:
body: \0\0\0\0t\n#\x08\x01\x12\x06Note 1\x1a\tContent 1\"\x0cPost image 1\n#\x08\x02\x12\x06Note 2\x1a\tContent 2\"\x0cPost image 2
Expand Down

0 comments on commit f3cf2f1

Please sign in to comment.