graphql-dotnet / graphql-dotnet/graphql-client

Subscription not getting data even after client succesfully connects

Open
#389 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
648
Forks
136
PR merge metrics
No merged PRs in 30d

Description

Hello,

I'm using Spring Boot Netflix DGS as my graph server, trying to connect with C# as a client for a subscription

While looking through the other issues posted on here ive pieced this together, this is a basic new c# console app, so im just keeping while true to stop the app from exiting after subscribing to the subscription. I can see on my java server the log message client connected, but I don't get any data back from the subscription. I can confirm the subscription works with other tools like apollo playground. I'm not geting any error, just not geting any data back.

Java server code

` @DgsSubscription
public Publisher gameStates() {
log.info("Client connected");
return gameService.getGameStatePublisher();
}`

### C# Code

` var gameStateSubscriptionRequest = new GraphQLRequest
{
Query = @"
subscription{
gameStates{
id
}
}"
};

// Create JsonSerializer
var serializerSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver { IgnoreIsSpecifiedMembers = true },
MissingMemberHandling = MissingMemberHandling.Ignore
};
serializerSettings.Converters.Add(new ConstantCaseEnumWorkaroundConverter());

// See https://github.com/graphql-dotnet/graphql-client/issues/311
var jsonSerializer = new NewtonsoftJsonSerializer(serializerSettings);

// Establish Client
var _subscriptionClient = new GraphQLHttpClient(o =>
{
o.WebSocketEndPoint = new Uri("ws://localhost:8080/subscriptions");
o.UseWebSocketForQueriesAndMutations = false;
},
jsonSerializer);

var subscriptionStream = _subscriptionClient.CreateSubscriptionStream(gameStateSubscriptionRequest);

var subscription = subscriptionStream.Subscribe(response =>
{
Console.WriteLine("Data is");
Console.WriteLine(response.Data);
});

while (true)
{
}`


Screen Shot 2022-05-12 at 11 08 03 PM


Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.