Skip to content

use_query and use_mutation #86

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

Merged
merged 60 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
c01152a
wip use_query and use_mutation
rmorshea Jul 2, 2022
86b6575
fetch deferred attrs
rmorshea Jul 15, 2022
780251c
update comment
rmorshea Jul 15, 2022
e465055
use dataclass instead of namedtuple
rmorshea Jul 15, 2022
adc69b6
sort imports
rmorshea Jul 15, 2022
84f8332
move undefined to types module
Archmonger Jul 26, 2022
e618868
formatting
Archmonger Jul 26, 2022
2d8d9e9
attempt fix for checkout warning
Archmonger Jul 26, 2022
70e3c91
fix docs typo
Archmonger Jul 26, 2022
f3b1d9e
add to changelog
Archmonger Jul 26, 2022
f920ae6
change event function name
Archmonger Jul 26, 2022
2c2e4e1
separate query/mutation docs
Archmonger Jul 26, 2022
725995b
enable link checking
Archmonger Jul 26, 2022
196c7ba
verbose link checking
Archmonger Jul 26, 2022
6180719
bump setup python version
Archmonger Jul 26, 2022
ae7c754
bump setup node
Archmonger Jul 26, 2022
b1b1552
fix task name
Archmonger Jul 26, 2022
01c427f
Update src/django_idom/hooks.py
Archmonger Jul 26, 2022
5c81104
Merge branch 'use_database' of https://github.com/idom-team/django-id…
Archmonger Jul 26, 2022
da9f4ce
Can `use_mutation` trigger refetch of a `use_query`
Archmonger Jul 26, 2022
08950d9
wordsmith
Archmonger Jul 26, 2022
d67f9b4
event["target"]["value"]
Archmonger Jul 29, 2022
6cb01fa
Ignore some type hints
Archmonger Jul 30, 2022
1317701
add ORM clarification
Archmonger Jul 30, 2022
308b5d1
misc fixes + remove fetch_deferred_fields
rmorshea Jul 30, 2022
7327106
remove unused code
Archmonger Jul 30, 2022
668ffc3
More typehint cleanup
Archmonger Jul 30, 2022
4c3de35
put deferred fetch back
rmorshea Aug 2, 2022
8f73020
switch from selenium to playwright
rmorshea Aug 2, 2022
7b6ced3
add basic test
rmorshea Aug 2, 2022
0b5c1fd
fix style
rmorshea Aug 2, 2022
02936e3
headless by default
rmorshea Aug 2, 2022
f437106
increase DB timeout
Archmonger Aug 2, 2022
acfe4e5
add todo item to admin site
Archmonger Aug 2, 2022
aa6139a
fix item done toggle
Archmonger Aug 2, 2022
e56255e
format
Archmonger Aug 2, 2022
8595c4e
attempt using onChange as devtools suggests
Archmonger Aug 2, 2022
a007566
remove accidental sleep
Archmonger Aug 2, 2022
093fc36
try to fix tests
rmorshea Aug 9, 2022
83b2d01
fix setup.py for deprecated distutils
rmorshea Aug 14, 2022
6a754cf
use propper skip error
rmorshea Aug 14, 2022
3d336b3
bump idom dep
rmorshea Aug 14, 2022
38de554
Fix context type hint
Archmonger Aug 14, 2022
5203f0d
bump idom
Archmonger Sep 12, 2022
1f2ed01
remove unused import
rmorshea Sep 13, 2022
ab07327
Merge branch 'main' into use_database
rmorshea Sep 13, 2022
0b8013c
no mypy on tests
rmorshea Sep 13, 2022
fd09362
bump idom-client-react
Archmonger Sep 13, 2022
1e1d979
bump idom version
rmorshea Sep 13, 2022
a53ece4
add delay to typing
rmorshea Sep 13, 2022
ca289d0
revert idom.html changes in tests
Archmonger Sep 14, 2022
281c5af
clean up noxfile
Archmonger Sep 14, 2022
949e815
bump idom client
Archmonger Sep 14, 2022
80b1471
Merge branch 'use_database' of https://github.com/idom-team/django-id…
Archmonger Sep 14, 2022
ba42a8b
Move mutation and query to types.py
Archmonger Sep 14, 2022
b174a80
Python < 3.10 compatibility
Archmonger Sep 14, 2022
0324b06
Revert "Python < 3.10 compatibility"
Archmonger Sep 14, 2022
19806cb
from __future__ import annotations
Archmonger Sep 14, 2022
f672798
remove TransactionTestCase
Archmonger Sep 15, 2022
81928fb
revert channels login changes
Archmonger Sep 15, 2022
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
10 changes: 5 additions & 5 deletions src/django_idom/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Callable[..., Callable[..., Awaitable[Any]]],
_database_sync_to_async,
)
WebsocketContext: Context[IdomWebsocket | None] = create_context(None)
WebsocketContext: Context[Union[IdomWebsocket, None]] = create_context(None)
_REFETCH_CALLBACKS: DefaultDict[
Callable[..., Any], set[Callable[[], None]]
] = DefaultDict(set)
Expand Down Expand Up @@ -45,10 +45,10 @@ def use_websocket() -> IdomWebsocket:


def use_query(
query: Callable[_Params, _Result | None],
query: Callable[_Params, Union[_Result, None]],
*args: _Params.args,
**kwargs: _Params.kwargs,
) -> Query[_Result | None]:
) -> Query[Union[_Result, None]]:
query_ref = use_ref(query)
if query_ref.current is not query:
raise ValueError(f"Query function changed from {query_ref.current} to {query}.")
Expand Down Expand Up @@ -96,8 +96,8 @@ def execute_query() -> None:


def use_mutation(
mutate: Callable[_Params, bool | None],
refetch: Callable[..., Any] | Sequence[Callable[..., Any]],
mutate: Callable[_Params, Union[bool, None]],
refetch: Union[Callable[..., Any], Sequence[Callable[..., Any]]],
) -> Mutation[_Params]:
loading, set_loading = use_state(False)
error, set_error = use_state(cast(Union[Exception, None], None))
Expand Down
4 changes: 2 additions & 2 deletions src/django_idom/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Query(Generic[_Data]):

data: _Data
loading: bool
error: Exception | None
error: Union[Exception, None]
refetch: Callable[[], None]


Expand All @@ -39,5 +39,5 @@ class Mutation(Generic[_Params]):

execute: Callable[_Params, None]
loading: bool
error: Exception | None
error: Union[Exception, None]
reset: Callable[[], None]