You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently learning graphene the hard way, and I've been trying to get some info out of it via print and, when that didn't work, by raising exceptions. It appears that custom exceptions make the query partly fail (it seems to return None in place of the object that fails and continues going), but do not get bubbled up at all.
For example:
class Query(ObjectType): # everything should be a relay.Node but this, since it's the base of our schema.
user = Field(User) # current user
node = relay.NodeField()
@resolve_only_args
def resolve_user(self, **args):
raise Exception(args)
return User(id=1, user_id=1) # todo
schema = Schema(query=Query, auto_camelcase=False)
with the following test code:
In [8]: res2 = schema.execute("query { user {user_id} }")
In [9]: print res2.errors, res2.invalid, res2.data
[GraphQLError('{}',)] False OrderedDict([('user', None)])
shows that graphql is clearly swallowing custom exceptions, and then returning them as part of errors; doing this appears to lose the stack trace (and also makes sys.exc_info() useless). This makes it impossible to integrate with my usual exception monitoring, since we need either the original exc_info or the ability to report or reraise the original exception when it's first caught. While the query being executed is useful to know about, having the original stack trace is far more valuable and only the "which piece of the query was being executed" is really unique - our exception handling code already handles getting request params for us.
Any of the following solutions would work for me:
don't swallow the exceptions, just raise them; this avoids doing extra work, since we might want to just 500 these failing request anyway to encourage developers to notice & fix them. Maybe could be implemented with a Plugin?
return the exc_info of each exception as part of errors. This seems simplest.
have some sort of on_exception hook availabe that would run within the except block that's currently swallowing these exceptions, that could handle the reporting.
The text was updated successfully, but these errors were encountered:
Currently learning graphene the hard way, and I've been trying to get some info out of it via
print
and, when that didn't work, by raising exceptions. It appears that custom exceptions make the query partly fail (it seems to returnNone
in place of the object that fails and continues going), but do not get bubbled up at all.For example:
with the following test code:
shows that graphql is clearly swallowing custom exceptions, and then returning them as part of
errors
; doing this appears to lose the stack trace (and also makessys.exc_info()
useless). This makes it impossible to integrate with my usual exception monitoring, since we need either the originalexc_info
or the ability to report or reraise the original exception when it's first caught. While the query being executed is useful to know about, having the original stack trace is far more valuable and only the "which piece of the query was being executed" is really unique - our exception handling code already handles getting request params for us.Any of the following solutions would work for me:
exc_info
of each exception as part oferrors
. This seems simplest.on_exception
hook availabe that would run within theexcept
block that's currently swallowing these exceptions, that could handle the reporting.The text was updated successfully, but these errors were encountered: