Add before_execute and after_execute callbacks
yuki24 opened this issue · 0 comments
yuki24 commented
Use cases
- They are useful for application-level logging and analytics
before_execute
is specifically useful when e.g. needing to assign a header to every request on the flyafter_execute
is specifically useful when e.g. needing to raise an exception when the HTTP status is 5xx (could be user's choice)
Exmaples
class Metaphysics < Artemis::Client
before_execute do |document, operation_name, variables, context|
# do stuff before making a GraphQL request
end
after_execute do |data, errors|
# do stuff after receiving a GraphQL response
end
...
end