pathom

2024-07-19T17:05:46.187339Z

is there a builtin way in Pathom 3 to have optional ("conditional"?) outputs on resolvers? I have a bulk resolver that's effectively doing a SQL SELECT for a bunch of fields. there's a couple of fields that are possibly large embedded JSON values. only some consumers of this resolver need that large field. IIUC the planner knows whether those fields are needed by the query, but it doesn't seem to tell the resolver that. I could roll my own with a parameter set at query time, I suppose.

wilkerlucio 2024-07-19T17:46:03.342539Z

every output is potentially optional in the view of Pathom 3

wilkerlucio 2024-07-19T17:46:28.889929Z

all validity checks are on the input side, never on the output

wilkerlucio 2024-07-19T17:47:50.059829Z

the approach I recommend in cases like you described is to place all output options in the output description, and in the resolver look for the expects part of the node, which will tell you which attributes are actually needed in the current execution context

wilkerlucio 2024-07-19T17:48:30.337879Z

env -> pcp/node -> pcp/expects

2024-07-19T21:37:56.063729Z

Ah, cool. Thanks for the pointer!