-
Notifications
You must be signed in to change notification settings - Fork 136
Create new GraphQLHttpWebSocket instance if needed #252
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
Conversation
| HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(GetType().Assembly.GetName().Name, GetType().Assembly.GetName().Version.ToString())); | ||
|
|
||
| _graphQlHttpWebSocket = new GraphQLHttpWebSocket(GetWebSocketUri(), this); | ||
| if (options.UseWebSocketForQueriesAndMutations) |
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.
Subscriptions must always use the websocket connection (obviously they don't work with regular HTTP requests).
You need to make sure that an instance of GraphQLHttpWebSocket is present when a subscription is created, otherwise you will receive a null reference exception on creating a subscription.
rose-a
left a comment
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.
OK, one last thing: Would you please use Lazy<GraphQLHttpWebSocket> instead of GetGraphQLHttpWebSocket()?
This has thread-safety already builtin...
|
To instantiate a GraphQLHttpWebSocket requires a call into an instance method and pass an instance reference (/* public GraphQLHttpWebSocket(Uri webSocketUri, GraphQLHttpClient client) */ ) |
|
I think its well described in the API Reference. Create a private field for a Then you access the actual instance of |
|
Thx, I have moved the initialization into the ctor, that was the problem. |
Dispose if has value Co-authored-by: Alexander Rose <alex@rose-a.de>
Create new GraphQLHttpWebSocket instance if the UseWebSocketForQueriesAndMutations is true