walmartlabs/lacinia

Tracing "validation" fields are always null

favila opened this issue · 0 comments

When using the "tracing" extension (e.g. the lacinia-timing header in pedestal), the "validation" field always looks like {:startOffset nil, :duration nil} instead of having an offset and duration.

I believe this is because lacinia execute-query pulls the ::timing/validation entry off the context map instead of the parsed-query map.

Both com.walmartlabs.lacinia.pedestal.internal/on-enter-prepare-query and com.walmartlabs.lacina/execute-parsed-query-async seem to add this to the parsed-query map, not its parent map.

As a workaround in lacinia-pedestal, I insert the following interceptor somewhere in-between l.pedestal2/prepare-query-interceptor and l.pedestal2/query-executor-handler to copy the validation data to the place execute-query expects, although I think execute-query is probably the code that should change here.

(interceptor
     {:enter (fn [pctx]
               (update-in pctx [:request :lacinia-app-context] conj
                          (find (-> pctx :request :parsed-lacinia-query)
                                :com.walmartlabs.lacinia.tracing/validation)))})