Comments (29)
Is there any work that needs to be done on this still? We wanted to use this for our integration test environment and discovered that the NuGet package version does not include the Subscription code.
from graphql-client.
What is the plan to incorporate Subscription Code in Stable version of this library?
from graphql-client.
@deinok To just receive update data the event ist propably sufficient and also easily wrapped into an IObservable
. Also the parts using System.Reactive
cannot target .NET Standard 1.3
.
Where observables would be superior is in recognizing a terminating server, connection errors or ending sequences (which I don't have a useful offhand example for, but they can be done using GraphQL.NET and GraphQL.Server) in that they communicate an error or the completion of the sequence, so the application could react properly. Of course a similar result could also be achieved by implementing 2 new events, but IMO this would be quite inferior.
I'll think up a proposal and eventually do a PR if it's ready for discussion...
from graphql-client.
Hi Team, .NET Core 3.0 version is release now. There was information somewhere that GraphQL.Clinet stable version Subscription Code would be released in align with .NET Core 3.0.
Do we have any update on that please?
from graphql-client.
@saba-sabrin Todey i will create a sample
from graphql-client.
To anybody interested, we have created a branch called "subscriptions-api" in order to estabilize the API, but seems like using System.Reactive
will be the way to go.
Also, many thanks to @rose-a for his work ;)
from graphql-client.
@deinok Regarding the local test server take a peek at the IntegrationTestServer in the subscriptions-api branch...
from graphql-client.
If using WebSockets there are two viable ways:
- https://github.com/sta/websocket-sharp & https://www.nuget.org/packages/WebSocketSharp
- System.Net.WebSockets.ClientWebSocket & https://www.nuget.org/packages/System.Net.WebSockets.Client
from graphql-client.
Hi, I have tried the Subscription example to subscribe for a GraphQL subscription request. But, apparently, it is not receiving any notifications for the subscription. Could you please recheck the example and provide a concrete solution on how we can subscribe properly and listen to the incoming notifications? Would be really great and appreciated !! Looking forward to your reply. Thanks.
from graphql-client.
@saba-sabrin Todey i will create a sample
@deinok That will be really a great help! I have used the code provided under "GraphQL.Client.Sample" project. My subscription connection was hopefully created, because I didn't receive any error. The problem is, My "OnReceive" event is never invoked inside the application. It would be also nice if possible then, provide a few details on how we can create a Web-Socket based subscription with token based authentication if necessary. Thanks a lot!
from graphql-client.
@saba-sabrin ref: graphql-dotnet/server#168
If you know about any public server that have subscriptions enabled I can use that server, until we have the our sample server
from graphql-client.
@deinok This is my code for using the subscription based on provided subscription usage:
ref: graphql-client/samples/GraphQL.Client.Sample/Program.cs
I can't share the GraphQL API details as of it belongs to my client and I'm using their private server. The API also uses token based authentication. That's why I need an example of proper usage of subscription and notification reception.
This is my GraphQL query:
var Query = @"subscription {
deviceCharacteristic {
node {
characteristicType
characteristicValue
deviceId
deviceDisplayName
}
}
}";
// Simple delegate for checking "OnReceive" event data
EventCheck eventCheckHandler = EventChecker;
// Function for subscription request using GraphQL Client
using (var graphQLHttpClient = new GraphQLHttpClient("ws://....")) // Websocket based URL
{
var subscriptionResult = graphQLHttpClient.SendSubscribeAsync(Query).Result;
subscriptionResult.OnReceive += (res) => {
Console.WriteLine("received event.");
eventCheckHandler(res);
};
Console.ReadKey();
}
// Delegate declaration
public delegate void EventCheck(GraphQLResponse res);
public void EventChecker(GraphQLResponse res)
{
var response = res.Data;
Console.WriteLine("Event detected");
}
from graphql-client.
Try this and report back.
you set the event handler but the background thread that reads the websocket is not started
var subscriptionResult = graphQLHttpClient.SendSubscribeAsync(Query).Result;
subscriptionResult.StartAsync();
subscriptionResult.OnReceive += (res) => {
Console.WriteLine("received event.");
eventCheckHandler(res);
};
from graphql-client.
@deinok As you can see in the above screenshot, the "StartAsync" method is not found. I think, there are some ambiguity in the interface implementation in the class "GraphQLHttpSubscriptionResult". The "SendSubscribeAsync" method returns "IGraphQLSubscriptionResult" and this interface has no "StartAsync" method definition. Could you please have a look? Thanks.
from graphql-client.
Try cast to GraphQLHttpSubscriptionResult
first what you have found is an error
from graphql-client.
@deinok I casted the response and tried with "StartAsync" method and this gives me an exception that, "The WebSocket has already been started".
Could you please check the "SendSubscribeAsync()" method in the "GraphQLHttpClient" class? The "StartAsync" method has already been called there too! Any suggestions?
from graphql-client.
Hmmm not for now. Awaiting for this -> graphql-dotnet/server#168
NVM, you server-backend, what language is using?
from graphql-client.
@deinok The GraphQL server backend is running in Golang.
https://github.com/99designs/gqlgen
I don't have much information about it other than the GraphQL related API conventions. Please inform when there are some subscription related updates. Thanks!
from graphql-client.
@deinok Any update on the subscription and notification event receiving part with the graphql-client library? Thanks.
from graphql-client.
I just need an open subscription server to run the tests
from graphql-client.
What about making IGraphQLSubscriptionResult
an IObservable<GraphQLResult>
(like in GraphQL.NET Subscriptions?
from graphql-client.
@rose-a Like a month ago I talked with the guys behind Rx.NET asking if for my case is better use events and delegates or use Reactive Extensions (Observables).
Seems like events do the same job. Mostly, the diference is returning an observable or an object with an event.
But I could be wrong, so if you have an idea of a better API, please share it with us.
from graphql-client.
@rose-a NETStandard1.3 is not a big issue, the library can be move to just NETStandard2.0 (This will also allow us simplificate some code)
Some general tips:
- The IMPLEMENTATION MUST use
ClientWebSocket
- Code that "could be shared" with an implementation of a Server goes to
Common
, Client code to theClient
- The API Surface MUST dont care if the subscription is done via
ClientWebSocket
or any other way. - The API Surface MUST don't care of the subscription implementation
- The IMPLEMENTATION can be the Apollo Subscription implementation (I'm not sure if there is a specification for that).
- client.Dispose() MUST close all
ClientWebSockets
directly or indirectly - "IGraphQLSubscriptionResult.Dispose() or your equivalent" MUST close its
ClientWebSockets
directly or indirectly
And I think that I don't left anything. NVM, if you can create an API like that I will pay you a beer, I'm not joking
from graphql-client.
@deinok I'm wondering if there is anything missing to the subscription API which prevents it to be merged into master (except from housekeeping)? Did you get around to review the current status of it?
from graphql-client.
@rose-a No, theres any problem with your subscription API. The main problem are some personal problems that makes me unable to fully review this. Finally this personal problems are solved and I'm back to the development.
The priority order is to move the library to use the nullable references, then add a local server to run the tests against, fix some issue mostly with authentication and then merge your API. So I expect that the next weekend we will be able to merge your API and finally release V2.0.0
from graphql-client.
Ty, thanks for the reminder
from graphql-client.
@deinok Any estimate when this might be incorporated into the big picture? If you need help somewhere don't mind to ask!
from graphql-client.
@deinok Any info of when Subscriptions will be in?
from graphql-client.
merged with #150
from graphql-client.
Related Issues (20)
- Invalid Cast Exception when using Subscriptions HOT 2
- AppSync Subscription error: 'SubProtocolNotSupportedError' HOT 6
- Error in a Mutation Execution of 6.0.1 Nuget Version HOT 2
- 6.0.1 - System.ObjectDisposedException (SendWebSocketMessageAsync) HOT 1
- Getting "System.Net.Http.HttpRequestException: No such host is known" on Windows HOT 1
- Upgrade from 4.0.2 to 6.0.1 results in InitializeWebsocketConnection() error
- Casting Error in GraphQL C# Library HOT 4
- MapConverter throws if extensions property is null
- .NET 8.0 Issue w/ SystemTextJsonSerializer HOT 1
- SendQueryAsync fails unless Uri has a trailing '/' HOT 1
- GraphQL.Client.Example fails with exception
- Subscription disposed but connection remains HOT 4
- first and take not working properly? HOT 2
- How to use Polly with this library? HOT 1
- AppSync's WS connection closing at initialization
- Json Serialiser doesn't handle structs well and ignores type converters HOT 11
- Make it easier to use GraphQL’s constructor with HttpClient and only endpoint
- System.Text.Json.JsonException when parsing response from SendMutationAsync. HOT 1
- Please consider adding [StringSyntax("GraphQL")] attributes HOT 4
- Unused project reference to Newtonsoft.Json in GraphQL.Client.LocalExecution
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-client.