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
graphqllibrary
You can install the graphql library using pip:
pip install graphql-corepython main.py [options] [arguments]-d directory_path output_file.sdl- Read
.gqlfiles from the specified directory and write the schema tooutput_file.sdl.
- Read
-f file1.gql file2.gql ... output_file.sdl- Read the specified
.gqlfiles 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.sdlRead 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.sdlThe main() function handles the command-line arguments and calls the appropriate functions based on the provided switches (-d, -f, or -h).
- Ensure the
.gqlfiles are correctly formatted for the script to process them without errors.