Skip to content

Commit e6de771

Browse files
fix: proto-gen-nexus google type
1 parent 06bb308 commit e6de771

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

packages/@proto-graphql/codegen-core/src/printer/util.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,14 @@ export function isProtobufWrapperType(
247247
);
248248
}
249249

250+
export function isGoogleWellKnownType(
251+
proto: ProtoField["type"]
252+
): proto is ProtoMessage {
253+
return (
254+
proto.kind === "Message" && proto.file.name.startsWith("google/type/")
255+
);
256+
}
257+
250258
export function isProtobufWellKnownType(
251259
proto: ProtoField["type"]
252260
): proto is ProtoMessage {

packages/protoc-gen-nexus/src/dslgen/printers/field.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
InputObjectType,
77
InterfaceType,
88
isProtobufLong,
9+
isGoogleWellKnownType,
910
isProtobufWellKnownType,
1011
ObjectField,
1112
ObjectOneofField,
@@ -251,7 +252,7 @@ function createResolverCode(
251252
}
252253
}
253254

254-
if (isProtobufWellKnownType(field.proto.type)) {
255+
if (isProtobufWellKnownType(field.proto.type)|| isGoogleWellKnownType(field.proto.type)) {
255256
const transformer = code`${impProtoNexus(
256257
"getTransformer"
257258
)}("${field.proto.type.fullName.toString()}")`;

packages/protoc-gen-nexus/src/dslgen/printers/inputObjectType.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
InputObjectField,
55
InputObjectType,
66
isProtobufLong,
7+
isGoogleWellKnownType,
78
isProtobufWellKnownType,
89
protobufGraphQLExtensions,
910
protoType,
@@ -93,7 +94,7 @@ export function createToProtoFuncCode(
9394
type.fields.map((f) => {
9495
let wrapperFunc: (v: Code) => Code = (v) => v;
9596
if (f.type instanceof ScalarType) {
96-
if (isProtobufWellKnownType(f.proto.type)) {
97+
if (isProtobufWellKnownType(f.proto.type) || isGoogleWellKnownType(f.proto.type)) {
9798
const protoFullName = f.proto.type.fullName.toString();
9899
const transformer = code`${impProtoNexus(
99100
"getTransformer"

0 commit comments

Comments
 (0)