mirror of
				https://github.com/graphql-python/graphene.git
				synced 2025-11-04 01:47:45 +03:00 
			
		
		
		
	Improved django execute view
This commit is contained in:
		
							parent
							
								
									b4b7783ed1
								
							
						
					
					
						commit
						979dd0f498
					
				| 
						 | 
					@ -30,12 +30,12 @@ class GraphQLView(View):
 | 
				
			||||||
            } for e in errors]
 | 
					            } for e in errors]
 | 
				
			||||||
        return HttpResponse(json.dumps({'errors': errors}), content_type='application/json')
 | 
					        return HttpResponse(json.dumps({'errors': errors}), content_type='application/json')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def execute_query(self, request, query):
 | 
					    def execute_query(self, request, query, *args, **kwargs):
 | 
				
			||||||
        if not query:
 | 
					        if not query:
 | 
				
			||||||
            return self.response_errors(Exception("Must provide query string."))
 | 
					            return self.response_errors(Exception("Must provide query string."))
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                result = self.schema.execute(query, root=object())
 | 
					                result = self.schema.execute(query, *args, **kwargs)
 | 
				
			||||||
                data = self.format_result(result)
 | 
					                data = self.format_result(result)
 | 
				
			||||||
            except Exception as e:
 | 
					            except Exception as e:
 | 
				
			||||||
                if settings.DEBUG:
 | 
					                if settings.DEBUG:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user