-
Notifications
You must be signed in to change notification settings - Fork 184
Closed
Labels
Description
The concept of graphql involves writing large but precise queries. Which are inconvenient to write as lines in the code. Many implementation of gql clients has a file-store queries as well as extensions for IDEs support syntax highlighting for .graphql
and .gql
files.
Feature request: add function for easy load query from .graphql
or .gql
files.
For example, add optional parameter file_patch
in gql (or file-like object), or create a separate function to load.
Implementation is also simple like this:
# https://github.com/graphql-python/gql/blob/master/gql/gql.py
def gql_from_file(file_path: str) -> DocumentNode:
with open(file_path) as f:
return gql(f.read())
# Call
from gql import gql_from_file
doc_node = gql_from_file('some_query.graphql')
I will be glad to make a pull request after the discussion :)