mirror of
				https://github.com/graphql-python/graphene-django.git
				synced 2025-11-04 09:57:53 +03:00 
			
		
		
		
	Merge branch 'master' into v3
This commit is contained in:
		
						commit
						fb90cb78b3
					
				
							
								
								
									
										34
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
---
 | 
			
		||||
name: Bug report
 | 
			
		||||
about: Create a report to help us improve
 | 
			
		||||
title: ''
 | 
			
		||||
labels: "\U0001F41Bbug"
 | 
			
		||||
assignees: ''
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
**Note: for support questions, please use stackoverflow**. This repository's issues are reserved for feature requests and bug reports.
 | 
			
		||||
 | 
			
		||||
* **What is the current behavior?**
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
* **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem** via
 | 
			
		||||
a github repo, https://repl.it or similar (you can use this template as a starting point: https://repl.it/@jkimbo/Graphene-Django-Example).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
* **What is the expected behavior?**
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
* **What is the motivation / use case for changing the behavior?**
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
* **Please tell us about your environment:**
 | 
			
		||||
  
 | 
			
		||||
  - Version: 
 | 
			
		||||
  - Platform: 
 | 
			
		||||
 | 
			
		||||
* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)
 | 
			
		||||
							
								
								
									
										1
									
								
								.github/ISSUE_TEMPLATE/config.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.github/ISSUE_TEMPLATE/config.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
blank_issues_enabled: false
 | 
			
		||||
							
								
								
									
										20
									
								
								.github/ISSUE_TEMPLATE/feature_request.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								.github/ISSUE_TEMPLATE/feature_request.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
---
 | 
			
		||||
name: Feature request
 | 
			
		||||
about: Suggest an idea for this project
 | 
			
		||||
title: ''
 | 
			
		||||
labels: "✨enhancement"
 | 
			
		||||
assignees: ''
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
**Is your feature request related to a problem? Please describe.**
 | 
			
		||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
 | 
			
		||||
 | 
			
		||||
**Describe the solution you'd like**
 | 
			
		||||
A clear and concise description of what you want to happen.
 | 
			
		||||
 | 
			
		||||
**Describe alternatives you've considered**
 | 
			
		||||
A clear and concise description of any alternative solutions or features you've considered.
 | 
			
		||||
 | 
			
		||||
**Additional context**
 | 
			
		||||
Add any other context or screenshots about the feature request here.
 | 
			
		||||
| 
						 | 
				
			
			@ -47,7 +47,7 @@ Custom resolvers
 | 
			
		|||
If your ``DjangoObjectType`` has defined a custom
 | 
			
		||||
:ref:`get_queryset<django-objecttype-get-queryset>` method, when resolving a
 | 
			
		||||
``DjangoListField`` it will be called with either the return of the field
 | 
			
		||||
resolver (if one is defined) or the default queryeset from the Django model.
 | 
			
		||||
resolver (if one is defined) or the default queryset from the Django model.
 | 
			
		||||
 | 
			
		||||
For example the following schema will only resolve recipes which have been
 | 
			
		||||
published and have a title:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,8 +9,8 @@ Graphene-Django provides some additional abstractions that make it easy to add G
 | 
			
		|||
First time? We recommend you start with the installation guide to get set up and the basic tutorial.
 | 
			
		||||
It is worth reading the `core graphene docs <https://docs.graphene-python.org/en/latest/>`__ to familiarize yourself with the basic utilities.
 | 
			
		||||
 | 
			
		||||
Core tenants
 | 
			
		||||
------------
 | 
			
		||||
Core tenets
 | 
			
		||||
-----------
 | 
			
		||||
 | 
			
		||||
If you want to expose your data through GraphQL - read the ``Installation``, ``Schema`` and ``Queries`` section.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -147,10 +147,10 @@ class NormalCursorWrapper(object):
 | 
			
		|||
            # We keep `sql` to maintain backwards compatibility
 | 
			
		||||
            self.logger.object.sql.append(_sql)
 | 
			
		||||
 | 
			
		||||
    def callproc(self, procname, params=()):
 | 
			
		||||
    def callproc(self, procname, params=None):
 | 
			
		||||
        return self._record(self.cursor.callproc, procname, params)
 | 
			
		||||
 | 
			
		||||
    def execute(self, sql, params=()):
 | 
			
		||||
    def execute(self, sql, params=None):
 | 
			
		||||
        return self._record(self.cursor.execute, sql, params)
 | 
			
		||||
 | 
			
		||||
    def executemany(self, sql, param_list):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -60,6 +60,31 @@ def test_should_query_simplelazy_objects():
 | 
			
		|||
    assert result.data == {"reporter": {"id": "1"}}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_should_query_wrapped_simplelazy_objects():
 | 
			
		||||
    class ReporterType(DjangoObjectType):
 | 
			
		||||
        class Meta:
 | 
			
		||||
            model = Reporter
 | 
			
		||||
            fields = ("id",)
 | 
			
		||||
 | 
			
		||||
    class Query(graphene.ObjectType):
 | 
			
		||||
        reporter = graphene.Field(ReporterType)
 | 
			
		||||
 | 
			
		||||
        def resolve_reporter(self, info):
 | 
			
		||||
            return SimpleLazyObject(lambda: SimpleLazyObject(lambda: Reporter(id=1)))
 | 
			
		||||
 | 
			
		||||
    schema = graphene.Schema(query=Query)
 | 
			
		||||
    query = """
 | 
			
		||||
        query {
 | 
			
		||||
          reporter {
 | 
			
		||||
            id
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
    """
 | 
			
		||||
    result = schema.execute(query)
 | 
			
		||||
    assert not result.errors
 | 
			
		||||
    assert result.data == {"reporter": {"id": "1"}}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_should_query_well():
 | 
			
		||||
    class ReporterType(DjangoObjectType):
 | 
			
		||||
        class Meta:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -269,12 +269,9 @@ class DjangoObjectType(ObjectType):
 | 
			
		|||
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def is_type_of(cls, root, info):
 | 
			
		||||
        if isinstance(root, SimpleLazyObject):
 | 
			
		||||
            root._setup()
 | 
			
		||||
            root = root._wrapped
 | 
			
		||||
        if isinstance(root, cls):
 | 
			
		||||
            return True
 | 
			
		||||
        if not is_valid_django_model(type(root)):
 | 
			
		||||
        if not is_valid_django_model(root.__class__):
 | 
			
		||||
            raise Exception(('Received incompatible instance "{}".').format(root))
 | 
			
		||||
 | 
			
		||||
        if cls._meta.model._meta.proxy:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user