-
Notifications
You must be signed in to change notification settings - Fork 31
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
Generate subscriptions as async generators #133
Conversation
pyproject.toml
Outdated
@@ -25,6 +25,7 @@ dependencies = [ | |||
"toml~=0.10", | |||
"httpx~=0.23", | |||
"pydantic~=1.10", | |||
"websockets~=11.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this dependency opt-in, eg. pip install ariadne-codegen[subscriptions]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I'm not sure if it's the right way. AsyncBaseClient
still depends on websockets
even when no subscription was generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should handle websockets
not being installed. Usual approach is handling the import error and importing placeholder object that implements the subset of API but raises not implemented error from its methods.
EXAMPLE.md
Outdated
|
||
For every provided query/mutation there is generated file, that contains models which correspond to return type of operation. File name is generated by converting query/mutation name to snake case. Root models has the same name as query/mutation, and depend classes use it as prefix in their names. | ||
For every provided query/mutation/subscription there is generated file, that contains models which correspond to return type of operation. File name is generated by converting operation name to snake case. Root models has the same name as query/mutation/subscription, and depend classes use it as prefix in their names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For every provided query/mutation/subscription there is generated file, that contains models which correspond to return type of operation. File name is generated by converting operation name to snake case. Root models has the same name as query/mutation/subscription, and depend classes use it as prefix in their names. | |
For every provided query/mutation/subscription there is a generated file that contains models which correspond to return type of operation. File name is generated by converting operation name to snake case. Root models has the same name as query/mutation/subscription, and depend classes use it as prefix in their names. |
Self = TypeVar("Self", bound="AsyncBaseClient") | ||
|
||
GQL_SUBPROTOCOL = "graphql-transport-ws" | ||
GQL_CONNECTION_INIT = "connection_init" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could group message types under an Enum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should mention in readme that websockets are optional dependency required for subscriptions.
resolves #65
Example of generated client: