question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Simplify tRPC Request/Response/Message Interfaces

See original GitHub issue

Originally posted by @KATT

See @jlalmes’ PR https://github.com/trpc/trpc/pull/1759

Potential things. Not definitive, just ideas.

Remove unused fields

Before:

[
  {
    "id": null,
    "result": {
      "type": "data",
      "data": {
        "id": "1",
        "title": "Hello tRPC",
        "body": "..."
        // ...
      }
    }
  },
]

After:

[
  {
    "result": {
      "data": {
        "id": "1",
        "title": "Hello tRPC",
        "body": "..."
        // ...
      }
    }
  },
]

Changed response to a mapped object

Potential ease of allowing for streaming… maybe we could start sending response as procedures are finalised and not wait for all of them to be finalized before returning… but it also breaks HTTP-codes so not sure.

Probably not a good idea, just a thought

{
  // 0 means index 0 of the batch
  "0": { 
    "id": null,
    "result": {
      "type": "data",
      "data": {
        "id": "1",
        "title": "Hello tRPC",
        "body": "..."
        // ...
      }
    }
  },
]

Remove JSONRPC

Remove JSNORPC stuff on the request/response for internal requests…

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
KATTcommented, Apr 13, 2022

Why don’t we also remove the result.data wrapper?

{ "greeting": "Hello tRPC" }

// batched request response
[
  { "greeting": "Hello tRPC" },
  { "greeting": "Hello tRPC2" }
]

It’s a good idea and I was thinking about that for a while but I probably will want to decorate responses with extra metadata in the future.

One of the ideas I’ve been toying with is an edge-cached tRPC service that could work a bit like GraphCDN - for that to work I would need to provide caching hints for each individual procedure.

1reaction
jlalmescommented, Apr 12, 2022

Is there a reason why we don’t we send these payloads as an array type?

To correctly serialize undefined: #669 (comment)

Thanks @sachinraja! Understood 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction to gRPC
This page introduces you to gRPC and protocol buffers. gRPC can use protocol buffers as both its Interface Definition Language (IDL) and as...
Read more >
1. Introduction to gRPC - gRPC: Up and Running [Book]
Inter-process communications are usually implemented using message passing with a synchronous request-response style or asynchronous event-driven styles.
Read more >
gRPC Tutorial: Using gRPC for Remote Procedural Calls
This guide shows how you can use gRPC, a open source remote procedure call framework which enables cross-platform communications between ...
Read more >
What is gRPC? Meaning, Architecture, Advantages ⚔️
gRPC is one of the latest developer approaches to API design that promises to solve problems that other design styles have failed to...
Read more >
Consider gRPC for Mobile APIs - Medium
gRPC and Protobuf precisely define an API service and auto generate iOS and Android client libraries. We evaluate gRPC request-response, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found