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

Support for Async Django #1394

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6a5b28d
Resolve DjangoObjectType getNode when in an async context
jaw9c Mar 30, 2023
74998af
Support Django Connection resolving in an async context
jaw9c Mar 30, 2023
f04f0d3
Support foriegn key connections running async
jaw9c Mar 30, 2023
e78fb86
handle regualr django lists
jaw9c Mar 30, 2023
28846f9
drop in an async view
jaw9c Mar 30, 2023
7ddaf9f
Handle coroutine results from resolvers in connections and filter con…
jaw9c Mar 31, 2023
ebbc578
Strange scope
jaw9c Mar 31, 2023
66938e9
async hates csrf
jaw9c Mar 31, 2023
1b2d5e0
handle async serlizer mutations
jaw9c Mar 31, 2023
0a84a6e
Handle async get_node
jaw9c Apr 2, 2023
64d311d
Copy tests for query to test async execution
jaw9c Apr 2, 2023
bdb8e84
Update cookbook for async testing
jaw9c May 4, 2023
4d5132d
Remove tests for now
jaw9c May 4, 2023
4e5862f
Add logging of errors in execution
jaw9c May 4, 2023
c10753d
most recent changes
jaw9c May 4, 2023
e9d5e88
Handle the default django list field and test the async execution of …
jaw9c May 5, 2023
76eeea4
Update tests for queries
jaw9c May 5, 2023
c501fdb
swap back to python 3.11
jaw9c May 5, 2023
58b92e6
linting
jaw9c May 5, 2023
791209f
Rejig concept to use middleware
jaw9c May 9, 2023
b69476f
improve async detection
jaw9c May 9, 2023
b134ab0
Handle custom Djangoconnectionresolvers
jaw9c May 9, 2023
8c068fb
Update to pull out mutations and ensure that DjangoFields don't get d…
jaw9c May 10, 2023
d3f8fcf
handle connections without middleware
jaw9c May 16, 2023
930248f
Refactor out async helper functions
jaw9c May 16, 2023
c27dd6c
cleanup middleware
jaw9c May 16, 2023
fba274d
refactor middleware
jaw9c May 16, 2023
84ba7d7
Remove unused path
jaw9c May 16, 2023
848536e
Clean up wrapped list resolver
jaw9c May 16, 2023
2659d67
updates tests
jaw9c May 16, 2023
c16276c
Merge branch 'main' into support-async
jaw9c May 16, 2023
37ebd63
follow main removing validate call
jaw9c May 16, 2023
5a19111
Fix graphiql for async
pcraciunoiu May 25, 2023
2ae927f
Merge branch 'main' into support-async
firaskafri Aug 10, 2023
28bc858
resolve conflicts and fix format
firaskafri Aug 10, 2023
45fb299
Fix bug when running sync view under asgi
jaw9c Aug 16, 2023
b35f3b0
Merge branch 'main' into support-async
firaskafri Feb 9, 2024
c2d601c
Fix newline
firaskafri Feb 9, 2024
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
Prev Previous commit
Next Next commit
Merge branch 'main' into support-async
  • Loading branch information
firaskafri authored Feb 9, 2024
commit b35f3b08e11830070d8d1c37a47f08296092a6d5
33 changes: 32 additions & 1 deletion graphene_django/tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest
from asgiref.sync import async_to_sync
from django.db.models import Count, Prefetch
from django.db.models import Count, Model, Prefetch

from graphene import List, NonNull, ObjectType, Schema, String
from graphene.relay import Node
Expand Down Expand Up @@ -851,3 +851,34 @@ def resolve_articles(root, info):
captured.captured_queries[1]["sql"],
)
assert_async_result_equal(schema, query, result)


class TestDjangoConnectionField:
def test_model_ordering_assertion(self):
class Chaos(Model):
class Meta:
app_label = "test"

class ChaosType(DjangoObjectType):
class Meta:
model = Chaos
interfaces = (Node,)

class Query(ObjectType):
chaos = DjangoConnectionField(ChaosType)

with pytest.raises(
TypeError,
match=r"Django model test\.Chaos has to have a default ordering to be used in a Connection\.",
):
Schema(query=Query)

def test_only_django_object_types(self):
class Query(ObjectType):
something = DjangoConnectionField(String)

with pytest.raises(
TypeError,
match="DjangoConnectionField only accepts DjangoObjectType types as underlying type",
):
Schema(query=Query)
You are viewing a condensed version of this merge commit. You can view the full changes here.