NavidK0 / SimpleGraphQL-For-Unity

A simple graphQL client that allows one to use .graphql files (or code) for queries, mutations, and subscriptions with Unity.
MIT License
34 stars 18 forks source link

Subscription listeners per subscription + support for graphql-transport-ws subprotocol #37

Closed Sewdn closed 2 years ago

Sewdn commented 2 years ago

PR fixes 2 issues:

  1. Separate your listeners per subscription, so you can know what data to expect from an update.
private Action<Challenge> subscriptionListener;
...
public void HandlePayload(string payload) {
    Debug.Log("Challenges subscription updated: " + payload);
    var responseType = new { Data = new { myActiveChallenges = new Challenge() }};
    subscriptionListener(JsonConvert.DeserializeAnonymousType(payload, responseType).Data.myActiveChallenges);
  }
  1. Support for graphql-transport-ws where:
    • authorization + other headers are set on init payload
    • subscribe/complete commands VS start/stop commands
NavidK0 commented 2 years ago

Heyo! Thank you so much for this. I sincerely appreciate it!

NavidK0 commented 2 years ago

In the future, I would like to add more abstraction for the different transports. It would allow for more flexibility and ease of maintenance. But, for now, I think this is fine!

Sewdn commented 2 years ago

@NavidK0 My pleasure! It's you that should be thanked for delivering and maintaining this package!