This script reads .gql
files from a specified directory or a list of files, processes the SDL content, builds a GraphQL schema, optionally extends the schema with custom elements, and writes the final schema to an output file with an .sdl
extension.
- Python 3.x
graphql
library
You can install the graphql
library using pip:
pip install graphql-core
python main.py [options] [arguments]
-d directory_path output_file.sdl
- Read
.gql
files from the specified directory and write the schema tooutput_file.sdl
.
- Read
-f file1.gql file2.gql ... output_file.sdl
- Read the specified
.gql
files and write the schema tooutput_file.sdl
.
- Read the specified
-h
- Show this help message.
Read all .gql
files from the specified directory and write the schema to output_schema.sdl
:
python main.py -d /path/to/directory output_schema.sdl
Read the specified .gql
files and write the schema to output_schema.sdl
:
python main.py -f /path/to/file1.gql /path/to/file2.gql output_schema.sdl
The main()
function handles the command-line arguments and calls the appropriate functions based on the provided switches (-d
, -f
, or -h
).
- Ensure the
.gql
files are correctly formatted for the script to process them without errors.