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

Docs improvement Subscriptions #376

Merged
merged 38 commits into from
Oct 11, 2023

Conversation

sdobbelaere
Copy link
Contributor

As referred to in issue #375 some improved guidance on getting subscriptions running including the missing pieces related to the test-server.

@codecov-commenter
Copy link

codecov-commenter commented Sep 27, 2023

Codecov Report

Attention: 27 lines in your changes are missing coverage. Please review.

Comparison is base (c15a66e) 88.00% compared to head (1bcbb67) 87.39%.
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #376      +/-   ##
==========================================
- Coverage   88.00%   87.39%   -0.61%     
==========================================
  Files          33       35       +2     
  Lines        2976     3023      +47     
==========================================
+ Hits         2619     2642      +23     
- Misses        357      381      +24     
Files Coverage Δ
strawberry_django/auth/queries.py 100.00% <100.00%> (ø)
strawberry_django/middlewares/debug_toolbar.py 58.33% <100.00%> (+0.35%) ⬆️
strawberry_django/permissions.py 79.81% <71.42%> (-0.31%) ⬇️
strawberry_django/auth/utils.py 63.15% <63.15%> (ø)
strawberry_django/routers.py 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bellini666 bellini666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice in general! :)

docs/guide/subscriptions.md Outdated Show resolved Hide resolved
docs/guide/subscriptions.md Outdated Show resolved Hide resolved
docs/guide/subscriptions.md Outdated Show resolved Hide resolved
docs/guide/subscriptions.md Outdated Show resolved Hide resolved
docs/guide/subscriptions.md Outdated Show resolved Hide resolved
docs/guide/subscriptions.md Outdated Show resolved Hide resolved
@sdobbelaere
Copy link
Contributor Author

  • Added the proposed improvements to the docs
  • Added a new router that is authentication enabled. (Original router doesn't provide the user object, thus not very batteries included as it needs fixing straight out of the box)
  • Consolidated how to find the user-object through get_current_user(info)

docs/guide/subscriptions.md Outdated Show resolved Hide resolved
strawberry_django/auth/queries.py Outdated Show resolved Hide resolved
strawberry_django/auth/queries.py Outdated Show resolved Hide resolved
strawberry_django/auth/queries.py Outdated Show resolved Hide resolved
strawberry_django/auth/queries.py Outdated Show resolved Hide resolved
strawberry_django/routers.py Show resolved Hide resolved
tests/projects/schema.py Outdated Show resolved Hide resolved
strawberry_django/auth/queries.py Outdated Show resolved Hide resolved
strawberry_django/auth/utils.py Outdated Show resolved Hide resolved
strawberry_django/auth/utils.py Outdated Show resolved Hide resolved
strawberry_django/auth/utils.py Outdated Show resolved Hide resolved
strawberry_django/auth/utils.py Outdated Show resolved Hide resolved
sdobbelaere and others added 2 commits September 30, 2023 22:56
Copy link
Member

@bellini666 bellini666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there :)

docs/guide/types.md Outdated Show resolved Hide resolved
strawberry_django/auth/utils.py Outdated Show resolved Hide resolved
@bellini666
Copy link
Member

@sdobbelaere I just solved the remaining pyright issues for you.

If the tests are passing fine, is there anything else missing from this or can it be merged?

docs/guide/subscriptions.md Outdated Show resolved Hide resolved
@sdobbelaere
Copy link
Contributor Author

sdobbelaere commented Oct 9, 2023

@sdobbelaere I just solved the remaining pyright issues for you.

If the tests are passing fine, is there anything else missing from this or can it be merged?

Thank you for the help, much appreciated.
The only thing left is commit b0a464a which allows you to manually set a user in the context for testing, on the condition that you mark it as "is_test_mode".

Why did I add this? Running tests needs access to a user in my case, this allows to construct a simple context when running tests like so:

from django.contrib.auth import get_user_model
from MyProject.schemas import schema

user = get_user_model().objects.last()
dummy_context = {'is_test_mode': True, 'user': user}

resp = schema.execute_sync(query=query, context_value=dummy_context)

Happy to add it to the docs.

strawberry_django/auth/utils.py Outdated Show resolved Hide resolved
@bellini666
Copy link
Member

@sdobbelaere I just solved the remaining pyright issues for you.
If the tests are passing fine, is there anything else missing from this or can it be merged?

Thank you for the help, much appreciated. The only thing left is commit b0a464a which allows you to manually set a user in the context for testing, on the condition that you mark it as "is_test_mode".

Why did I add this? Running tests needs access to a user in my case, this allows to construct a simple context when running tests like so:

from django.contrib.auth import get_user_model
from MyProject.schemas import schema

user = get_user_model().objects.last()
dummy_context = {'is_test_mode': True, 'user': user}

resp = schema.execute_sync(query=query, context_value=dummy_context)

Happy to add it to the docs.

As I mentioned there, I don't like that approach very much, specially because we have a way for forcing a user into the request: https://github.com/strawberry-graphql/strawberry-graphql-django/blob/main/strawberry_django/test/client.py#L75

You can see it being used in here for example: https://github.com/strawberry-graphql/strawberry-graphql-django/blob/main/tests/test_permissions.py#L49

Copy link
Member

@bellini666 bellini666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small nitpick and it should be good to merge :)

Thanks for taking the time to adjust everything I asked

docs/guide/unit-testing.md Outdated Show resolved Hide resolved
@sdobbelaere
Copy link
Contributor Author

Just a small nitpick and it should be good to merge :)

Thanks for taking the time to adjust everything I asked

yw :)

@bellini666 bellini666 merged commit 410edda into strawberry-graphql:main Oct 11, 2023
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants