graphql-python / graphql-server

This is the core package for using GraphQL in a custom server easily
MIT License
120 stars 72 forks source link

Fix bugs with transport-ws-protocol #111

Closed ayys closed 1 year ago

ayys commented 1 year ago

I am guessing the v3 branch was only used with GraphQLWSHandler, and not with GraphQLTransportWSHandler. That's probably why there were a bunch of bugs. This PR fixes the errors I got when trying to use subscriptions with the graphql-transport-ws protocol.

The first error I got was

Can't instantiate abstract class GraphQLTransportWSHandler with abstract method send_xjson

I implemented this function and the error went away.

Second error was with message types - they were TypedDicts, but typeddicts are essentially dicts. This means additional fields specified are not properly used. I fixed it by converting them to dataclasses and adding a to_dict field to it.