diff --git a/server/core/management/commands/export_schema_graphql.py b/server/core/management/commands/export_schema_graphql.py new file mode 100644 index 00000000..916bc051 --- /dev/null +++ b/server/core/management/commands/export_schema_graphql.py @@ -0,0 +1,21 @@ +from django.core.management import BaseCommand +from django.core.management import call_command +from django.conf import settings +import json +import os + + +class Command(BaseCommand): + def handle(self, *args, **options): + from api.schema import schema + from api.schema_public import schema as schema_public + + schema_path = os.path.join(settings.BASE_DIR, '..', 'schema.graphql') + public_schema_path = os.path.join(settings.BASE_DIR, '..', 'schema_public.graphql') + + with open(schema_path, 'w') as o: + o.write(str(schema)) + + with open(public_schema_path, 'w') as o: + o.write(str(schema_public)) +