Comments (6)
I haven't tested yet.
I will test as soon as possible and I will let you know.
Thank you.
from sahb.graphqlclient.
I'm on the sofa now lol, so can't examine in detail - but my immediate thought was that it might be a case issue. See #69
I find Wireshark a good tool for this kind of 'hidden' issue - look for the subscription request, the Ack, the sub messages being sent out. Often helps identify where the chain is broken.
FWIW....
from sahb.graphqlclient.
I have created a example for you:
using System;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SAHB.GraphQLClient;
using SAHB.GraphQLClient.FieldBuilder;
using SAHB.GraphQLClient.FieldBuilder.Attributes;
using SAHB.GraphQLClient.QueryGenerator;
using SAHB.GraphQLClient.Subscription;
namespace LiftStatus
{
class Program
{
static async Task Main(string[] args)
{
using (var wssClient = GraphQLSubscriptionWebSocketClient.Default())
{
// Connect
var graphQLSubscriptionClient = await wssClient.Connect(new Uri("ws://snowtooth.moonhighway.com/graphql"));
if (!graphQLSubscriptionClient.IsConnected)
{
Console.WriteLine("Could not connect!");
Console.ReadKey();
return;
}
// Initilize
await graphQLSubscriptionClient.Initilize();
if (!graphQLSubscriptionClient.IsInitilized)
{
Console.WriteLine("Could not initilize!");
Console.ReadKey();
return;
}
var operation = await graphQLSubscriptionClient.ExecuteOperation<Data>();
operation.DataRecieved += (sender, e) =>
{
Console.WriteLine("Lift changed: " + e.ReceivedData.Data.LiftStatusChange.Name);
};
IGraphQLHttpClient client = GraphQLHttpClient.Default();
while (true)
{
await SetLiftStatus(client, "astra-express", LiftStatus.OPEN);
Console.ReadKey();
}
}
}
static async Task<Lift> SetLiftStatus(IGraphQLHttpClient client, string id, LiftStatus liftStatus)
{
var output = await client.Execute<SetLiftStatus>(GraphQLOperationType.Mutation, url: "http://snowtooth.moonhighway.com/graphql", arguments:
new GraphQLQueryArgument[] { new GraphQLQueryArgument<SetLiftStatus>("id", id, e => e.Lift),
new GraphQLQueryArgument<SetLiftStatus>("status", liftStatus, e => e.Lift)});
return output.Lift;
}
}
public class Lift
{
public string Name { get; set; }
}
[JsonConverter(typeof(StringEnumConverter))]
public enum LiftStatus
{
[EnumMember(Value = "OPEN")]
OPEN,
[EnumMember(Value = "CLOSED")]
CLOSED,
[EnumMember(Value = "HOLD")]
HOLD
}
public class SetLiftStatus
{
[GraphQLArguments("id", "ID!", "id", true)]
[GraphQLArguments("status", "LiftStatus!", "status", true, true)]
[GraphQLFieldName("setLiftStatus")]
public Lift Lift { get; set; }
}
public class LiftStatusChange
{
public string Name { get; set; }
public int Capacity { get; set; }
}
public class Data
{
public LiftStatusChange LiftStatusChange { get; set; }
}
}
This produces the following output:
Note I'm using the latest version from develop - a preview NuGet feed is available (please see the readme) :)
Edit: If you remove e => e.Lift
in the SetLiftStatus it should work with the version on NuGet.
from sahb.graphqlclient.
Thank you so much!
I will test the example.
from sahb.graphqlclient.
@ClarenceMG Does it work?
from sahb.graphqlclient.
@sahb1239 your example is not working for me.
Apparently I subscribe but I never receive an answer, so I think the library disconnects very quickly.
I'm using Xamarin iOS 😕
from sahb.graphqlclient.
Related Issues (20)
- How do I add arguments to a model nested in the query? HOT 1
- .NET Standard versions HOT 1
- How do i pass multiple arguments to the same Query ? HOT 1
- Null dereference bug during deserialization
- GraphQLArgumentAttribute doens't exist? HOT 2
- Support for OperationName
- Not Auth header, just a token
- Introspection validation fails with enum in query HOT 2
- Support reconnecting GraphQLSubscriptionClient
- Implement IAsyncEnumerable on IGraphQLSubscriptionOperation
- Support Httpclientfactory in GraphQL Client Builder for usage with ASP.net Core
- Accessing the log messages HOT 1
- Add CancellationToken support HOT 2
- Custom scalars HOT 1
- Schema validation fails when fields are nullable HOT 7
- Subscription [GraphQL] errors not being caught HOT 9
- Creating GraphQL model using introspection
- Mutate Guidance HOT 2
- How do I transform the names of parameters for a class that is used as a query argument? HOT 3
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 sahb.graphqlclient.