Skip to content

Commit

Permalink
fix(grpc): mark array types as required (tailcallhq#1716)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddOnTop authored Apr 12, 2024
1 parent d55f5c4 commit 5596225
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/generator/from_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,13 @@ impl Context {

let label = field.label().as_str_name().to_lowercase();
cfg_field.list = label.contains("repeated");
cfg_field.required = label.contains("required");
cfg_field.required = label.contains("required") || cfg_field.list;

if field.r#type.is_some() {
let type_of = convert_ty(field.r#type().as_str_name());
if type_of.eq("JSON") {
cfg_field.list = false;
cfg_field.required = false;
}
cfg_field.type_of = type_of;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ input News__Author @tag(id: "news.Author") {
}

input News__MultipleNewsId @tag(id: "news.MultipleNewsId") {
ids: [News__NewsId]
ids: [News__NewsId]!
}

input News__News @tag(id: "news.News") {
Expand Down Expand Up @@ -75,7 +75,7 @@ type News {
}

type News__NewsList @tag(id: "news.NewsList") {
news: [News__News]
news: [News__News]!
}

type Query {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type News @tag(id: "News") {
}

type NewsList @tag(id: "NewsList") {
news: [News]
news: [News]!
}

type Query {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Person__Person @tag(id: "person.Person") {
email: String
id: Int!
name: String!
phone: [Person__PhoneNumber]
phone: [Person__PhoneNumber]!
stringMap: JSON
}

Expand Down

0 comments on commit 5596225

Please sign in to comment.