Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ts-proto snake_case to camelCase, Chat.gRPC.createRoom() empty id res field #770

Merged
merged 2 commits into from
Oct 26, 2023

Conversation

kon14
Copy link
Contributor

@kon14 kon14 commented Oct 26, 2023

This PR disables ts-proto's snake_case to camelCase conversions.
For whatever reason, ts-proto seems to match leading underscores as snake_case, even though they're technically not.

Example: message field _id would become Id
Besides being a nuisance, this resulted in generated types not really working as expected across server/client.
Eg: Chat module's createRoom was expected to return Id server-side and receive the same field client-side, but we actually received an empty string (default gRPC value) instead.

While at it, I also modified DeleteRoomRequests signature to also return _id (previously id as a workaround).
This should make the API consistent, while also matching the underlying db doc field naming.

The modifications in Chat's proto file are technically a breaking change, but I'm not denoting this via conventional commits as we're already in an alpha stage and the previous behavior was also sketchy at best.
At least node users of grpc-sdk should become aware of this following an SDK bump.

This change shouldn't break any in-code generated types usage as we only ever build internal Conduit protos + the official gRPC health check proto file, neither of which make use of snake_case naming.

I only slightly modified Authorization's nested Resource.Relation and Resource.Permission message types, removing the explicit underscore prefix (ts-proto doesn't use namespaces), which shouldn't really affect anything.
Relevant generated types are never explicitly referenced either anyway.

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other (please describe)

Does this PR introduce a breaking change?

  • Yes
  • No

The PR fulfills these requirements:

  • It's submitted to the main branch
  • When resolving a specific issue, it's referenced in the PR's description (e.g. fix #xxx, where "xxx" is the issue number)

@kkopanidis kkopanidis merged commit 510b2be into main Oct 26, 2023
6 checks passed
@kkopanidis kkopanidis deleted the fix-grpc-camel-case branch October 26, 2023 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants