# Path: gql/gql.py
# def gql(request_string: str) -> DocumentNode:
#     """Given a String containing a GraphQL request, parse it into a Document.
# 
#     :param request_string: the GraphQL request as a String
#     :type request_string: str
#     :return: a Document which can be later executed or subscribed by a
#         :class:`Client <gql.client.Client>`, by an
#         :class:`async session <gql.client.AsyncClientSession>` or by a
#         :class:`sync session <gql.client.SyncClientSession>`
# 
#     :raises GraphQLError: if a syntax error is encountered.
#     """
#     source = Source(request_string, "GraphQL request")
#     return parse(source)
# 
# Path: gql/utilities/parse_result.py
# def parse_result(
#     schema: GraphQLSchema,
#     document: DocumentNode,
#     result: Optional[Dict[str, Any]],
#     operation_name: Optional[str] = None,
# ) -> Optional[Dict[str, Any]]:
#     """Unserialize a result received from a GraphQL backend.
# 
#     :param schema: the GraphQL schema
#     :param document: the document representing the query sent to the backend
#     :param result: the serialized result received from the backend
#     :param operation_name: the optional operation name
# 
#     :returns: a parsed result with scalars and enums parsed depending on
#               their definition in the schema.
# 
#     Given a schema, a query and a serialized result,
#     provide a new result with parsed values.
# 
#     If the result contains only built-in GraphQL scalars (String, Int, Float, ...)
#     then the parsed result should be unchanged.
# 
#     If the result contains custom scalars or enums, then those values
#     will be parsed with the parse_value method of the custom scalar or enum
#     definition in the schema."""
# 
#     return parse_result_recursive(
#         schema, document, document, result, operation_name=operation_name
#     )
# 
# Path: tests/starwars/schema.py
# async def subscribe_reviews(_root, _info, episode):
# async def resolve_review(review, _info, **_args):


import pytest
from graphql import GraphQLError
from gql import gql
from gql.utilities import parse_result
from tests.starwars.schema import StarWarsSchema
    result = {}

    parsed_result = parse_result(StarWarsSchema, query, result)

    assert result == parsed_result


def test_invalid_result_raise_error():

    query = gql(
        """
        {
          hero {
            id
          }
        }
        """
    )

    result = {"hero": 5}

    with pytest.raises(GraphQLError) as exc_info:

        parse_result(StarWarsSchema, query, result)

    assert "Invalid result for container of field id: 5" in str(exc_info)


def test_fragment():


# Path: gql/gql.py
# def gql(request_string: str) -> DocumentNode:
#     """Given a String containing a GraphQL request, parse it into a Document.
# 
#     :param request_string: the GraphQL request as a String
#     :type request_string: str
#     :return: a Document which can be later executed or subscribed by a
#         :class:`Client <gql.client.Client>`, by an
#         :class:`async session <gql.client.AsyncClientSession>` or by a
#         :class:`sync session <gql.client.SyncClientSession>`
# 
#     :raises GraphQLError: if a syntax error is encountered.
#     """
#     source = Source(request_string, "GraphQL request")
#     return parse(source)
# 
# Path: gql/utilities/parse_result.py
# def parse_result(
#     schema: GraphQLSchema,
#     document: DocumentNode,
#     result: Optional[Dict[str, Any]],
#     operation_name: Optional[str] = None,
# ) -> Optional[Dict[str, Any]]:
#     """Unserialize a result received from a GraphQL backend.
# 
#     :param schema: the GraphQL schema
#     :param document: the document representing the query sent to the backend
#     :param result: the serialized result received from the backend
#     :param operation_name: the optional operation name
# 
#     :returns: a parsed result with scalars and enums parsed depending on
#               their definition in the schema.
# 
#     Given a schema, a query and a serialized result,
#     provide a new result with parsed values.
# 
#     If the result contains only built-in GraphQL scalars (String, Int, Float, ...)
#     then the parsed result should be unchanged.
# 
#     If the result contains custom scalars or enums, then those values
#     will be parsed with the parse_value method of the custom scalar or enum
#     definition in the schema."""
# 
#     return parse_result_recursive(
#         schema, document, document, result, operation_name=operation_name
#     )
# 
# Path: tests/starwars/schema.py
# async def subscribe_reviews(_root, _info, episode):
# async def resolve_review(review, _info, **_args):


# Path: tests/starwars/test_parse_results.py
import pytest
from graphql import GraphQLError
from gql import gql
from gql.utilities import parse_result
from tests.starwars.schema import StarWarsSchema

    result = {}

    parsed_result = parse_result(StarWarsSchema, query, result)

    assert result == parsed_result


def test_invalid_result_raise_error():

    query = gql(
        """
        {
          hero {
            id
          }
        }
        """
    )

    result = {"hero": 5}

    with pytest.raises(GraphQLError) as exc_info:

        parse_result(StarWarsSchema, query, result)

    assert "Invalid result for container of field id: 5" in str(exc_info)


def test_fragment():


    query = gql(