Giter Club home page Giter Club logo

Comments (29)

jaypeeZero avatar jaypeeZero commented on May 27, 2024 6

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.

SKGGitHub avatar SKGGitHub commented on May 27, 2024 5

What is the plan to incorporate Subscription Code in Stable version of this library?

from graphql-client.

rose-a avatar rose-a commented on May 27, 2024 2

@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.

SKGGitHub avatar SKGGitHub commented on May 27, 2024 2

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.

deinok avatar deinok commented on May 27, 2024 1

@saba-sabrin Todey i will create a sample

from graphql-client.

deinok avatar deinok commented on May 27, 2024 1

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.

rose-a avatar rose-a commented on May 27, 2024 1

@deinok Regarding the local test server take a peek at the IntegrationTestServer in the subscriptions-api branch...

from graphql-client.

deinok avatar deinok commented on May 27, 2024

If using WebSockets there are two viable ways:

from graphql-client.

saba-sabrin avatar saba-sabrin commented on May 27, 2024

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 avatar saba-sabrin commented on May 27, 2024

@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.

deinok avatar deinok commented on May 27, 2024

@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.

saba-sabrin avatar saba-sabrin commented on May 27, 2024

@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.

deinok avatar deinok commented on May 27, 2024

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.

saba-sabrin avatar saba-sabrin commented on May 27, 2024

gql

@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.

deinok avatar deinok commented on May 27, 2024

Try cast to GraphQLHttpSubscriptionResult first what you have found is an error

from graphql-client.

saba-sabrin avatar saba-sabrin commented on May 27, 2024

@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.

deinok avatar deinok commented on May 27, 2024

Hmmm not for now. Awaiting for this -> graphql-dotnet/server#168
NVM, you server-backend, what language is using?

from graphql-client.

saba-sabrin avatar saba-sabrin commented on May 27, 2024

@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.

saba-sabrin avatar saba-sabrin commented on May 27, 2024

@deinok Any update on the subscription and notification event receiving part with the graphql-client library? Thanks.

from graphql-client.

deinok avatar deinok commented on May 27, 2024

I just need an open subscription server to run the tests

from graphql-client.

rose-a avatar rose-a commented on May 27, 2024

What about making IGraphQLSubscriptionResult an IObservable<GraphQLResult> (like in GraphQL.NET Subscriptions?

from graphql-client.

deinok avatar deinok commented on May 27, 2024

@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.

deinok avatar deinok commented on May 27, 2024

@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 the Client
  • 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.

rose-a avatar rose-a commented on May 27, 2024

@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.

deinok avatar deinok commented on May 27, 2024

@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.

deinok avatar deinok commented on May 27, 2024

Ty, thanks for the reminder

from graphql-client.

rose-a avatar rose-a commented on May 27, 2024

@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.

ShearwaterJay avatar ShearwaterJay commented on May 27, 2024

@deinok Any info of when Subscriptions will be in?

from graphql-client.

rose-a avatar rose-a commented on May 27, 2024

merged with #150

from graphql-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.