Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Dump GraphQL schema in pre-commit hook #185

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ repos:
pass_filenames: false
require_serial: true
language: system
- id: graphql
name: graphql
description: "Dump GraphQL schema"
entry: python manage.py dump_graphql_schema
pass_filesnames: false
require_serial: true
language: system
15 changes: 15 additions & 0 deletions graphql_api/management/commands/dump_graphql_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from graphql_api.schema import schema
from graphql import print_schema

from django.core.management.base import BaseCommand, CommandParser

class Command(BaseCommand):
help = "Dump the full GraphQL schema to a file"

def add_arguments(self, parser: CommandParser) -> None:
pass

def handle(self, *args, **options) -> None:
content = print_schema(schema)
with open("graphql_api/schema.graphql", "w") as f:
f.write(content)
Loading
Loading