mirror of
				https://github.com/graphql-python/graphene-django.git
				synced 2025-11-01 00:17:38 +03:00 
			
		
		
		
	Merge pull request #512 from kalekseev/schema-to-stdout
Provide a way to dump schema to stdout.
This commit is contained in:
		
						commit
						f76f38ef30
					
				|  | @ -21,7 +21,7 @@ class CommandArguments(BaseCommand): | ||||||
|             type=str, |             type=str, | ||||||
|             dest="out", |             dest="out", | ||||||
|             default=graphene_settings.SCHEMA_OUTPUT, |             default=graphene_settings.SCHEMA_OUTPUT, | ||||||
|             help="Output file (default: schema.json)", |             help="Output file, --out=- prints to stdout (default: schema.json)", | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|         parser.add_argument( |         parser.add_argument( | ||||||
|  | @ -64,6 +64,9 @@ class Command(CommandArguments): | ||||||
| 
 | 
 | ||||||
|         indent = options.get("indent") |         indent = options.get("indent") | ||||||
|         schema_dict = {"data": schema.introspect()} |         schema_dict = {"data": schema.introspect()} | ||||||
|  |         if out == '-': | ||||||
|  |             self.stdout.write(json.dumps(schema_dict, indent=indent)) | ||||||
|  |         else: | ||||||
|             self.save_file(out, schema_dict, indent) |             self.save_file(out, schema_dict, indent) | ||||||
| 
 | 
 | ||||||
|             style = getattr(self, "style", None) |             style = getattr(self, "style", None) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user