Skip to content

Commit 996c6c0

Browse files
committed
when throwing an error, suggest PascalCase approximation
1 parent 046d237 commit 996c6c0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

protographic/src/operation-to-proto.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,12 @@ class OperationsToProtoVisitor {
268268
// This ensures exact matching between GraphQL operation names and RPC method names
269269
// PascalCase: starts with uppercase, contains at least one lowercase letter
270270
if (!/^[A-Z](?=.*[a-z])[a-zA-Z0-9]*$/.test(operationName)) {
271+
const suggestedName = upperFirst(camelCase(operationName));
271272
throw new Error(
272273
`Operation name "${operationName}" must be in PascalCase ` +
273274
`(start with uppercase letter, followed by mixed-case letters/numbers). ` +
274275
`Examples: GetUser, CreatePost, OnMessageAdded. ` +
276+
`Suggested name: "${suggestedName}". ` +
275277
`This ensures the RPC method name exactly matches the GraphQL operation name.`,
276278
);
277279
}

0 commit comments

Comments
 (0)