Add django command to generate a GraphQL SDL file
This commit is contained in:
parent
1f3b6fe40d
commit
dea4719fd1
|
|
@ -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))
|
||||
|
||||
Loading…
Reference in New Issue