walmartlabs / lacinia-pedestal

Expose Lacinia GraphQL as Pedestal endpoints
http://lacinia-pedestal.readthedocs.io/en/latest/
Other
200 stars 63 forks source link

Remove keys from the context on exit (leave or error) #110

Closed hlship closed 3 years ago

hlship commented 3 years ago

Pedestal's default top-level exception handler logs the entire Pedestal context; this is problematic with lacinia-pedestal, as the entire GraphQL query is inside the context, with numerous references to different parts of the compiled schema; logging this can be hundreds of kilobytes of output.

This PR ensures that, on exit (either normally, via the :leave callback, or via the :error callback) the values added to the context are removed, ensuring that the Pedestal context is (reasonably) clean by the time the top-level error reporting logic is hit.

This is important even in cases where the exception occurs outside of lacinia-pedestal, such as a problem streaming the JSON response to the client.