sachinraja / trpc-playground

playground for running tRPC queries in the browser
MIT License
288 stars 19 forks source link

Deeply nested objects are hidden #30

Closed ellis closed 1 year ago

ellis commented 1 year ago

Our endpoints have some deeply nested objects, and the tRPC Playground hides them after a certain depth. Can these be made visible? As is, I can't use the playground for testing such endpoints. Here's a simplified example, where the contents of aim are hidden:

{
    rows: [
        {
            keyToData: {
                SPAGT: {
                    aim: [Object]
                }
            }
        }
    ]
}
MatsDK commented 1 year ago

Hi, thanks for reporting this. This is happening because the object-inspect package is being used in this file to print out the response object and it defaults the depth to 5. If we want to print the whole object the depth option could be set to false or null

ellis commented 1 year ago

Thanks @MatsDK

I thought I would try to patch that myself for a quick workaround. I grepped index:2 and found it in node_modules/@trpc-playground/html/dist/assets/index.342a56e3.js. Appending ,depth:null didn't have the desired effect, though, and checking the Network tab in Chrome showed that the file is actually loaded from a CDN instead of locally (http://cdn.jsdelivr.net/npm/@trpc-playground/html@0.3.3/dist/assets/index.342a56e3.js).

Any suggestion for a quick workaround?

Another thought: If you happen to make depth configurable, could you make indent configurable too?

MatsDK commented 1 year ago

I don't know if the depth should be configurable, maybe it's better to set the depth to null by default and print the whole object. @sachinraja what do you think?

sachinraja commented 1 year ago

Yeah I don't want to offer configuration for this. Let's set the depth to null or use something better for displaying the result of queries/mutations (like react-json-tree).

sachinraja commented 1 year ago

fixed in 5916cd6129040cd76cdf9d8d448bb93863e4108b (v1.0.1)