2025-12-01

This commit is contained in:
2026-03-17 14:58:51 -06:00
parent 183e865f8b
commit 4b82b57113
6846 changed files with 954887 additions and 162606 deletions
@@ -0,0 +1,24 @@
from __future__ import annotations
from graphql import DocumentNode, Source, parse
def gql(request_string: str | Source) -> 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 | Source
: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.
"""
if isinstance(request_string, Source):
source = request_string
elif isinstance(request_string, str):
source = Source(request_string, "GraphQL request")
else:
raise TypeError("Request must be passed as a string or Source object.")
return parse(source)