Closed
@Checho3388

Description

I found out something confusing and wanted to know if maybe this could be a bug or if I'm missing something and this is an expected behavior.

This is my example.py file. It only has one resolver that raises an error.

from graphql import (GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLString, graphql_sync, )


def resolve_fail(*args, **kwargs):
    raise ValueError("Some error")


schema = GraphQLSchema(
    query=GraphQLObjectType(
        name='RootQueryType',
        fields={
            'hello': GraphQLField(
                GraphQLString,
                resolve=resolve_fail)
        }))

query = '{ hello }'

result = graphql_sync(schema, query)

I'm aware that result.errors[0] is a GraphQLError exception. But, I was expecting result.errors[0].original_error to be ValueError.

However, I can see that result.errors[0].original_error is a GraphQLError and result.errors[0].original_error.original_error is ValueError.

Is this ok?

>>> print(type(result.errors[0]))
<class 'graphql.error.graphql_error.GraphQLError'>
>>> print(type(result.errors[0].original_error))
<class 'graphql.error.graphql_error.GraphQLError'>
>>> print(type(result.errors[0].original_error.original_error))
<class 'ValueError'>