Add django command to generate a GraphQL SDL file

This commit is contained in:
Ramon Wenger 2021-02-22 17:14:10 +01:00
parent 1f3b6fe40d
commit dea4719fd1
1 changed files with 21 additions and 0 deletions

View File

@ -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))