You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wondering if it's possible to send a graphQL query with the gem :
For the moment , i just receive the welcome and ping message of an external websocket. ref:
Here is my code :
(I also added a header and subprotocol, but not sure if it's the right way to mention it too)
In my controller :
require 'websocket-client-simple'
require 'json'
url = "wss://ws.sorare.com/cable"
subprotocol = 'actioncable-v1-json'
header = {
"Authorization" => "Bearer #{ENV['S_TKN']}"
}
query = <<-GRAPHQL
subscription {
aCardWasUpdated { slug }
}
GRAPHQL
data = { 'query' => query, 'variables' => {} }
message = { 'command' => 'subscribe', 'identifier' => { 'channel' => 'MyChannel' }, 'data' => data }.to_json
client = WebSocket::Client::Simple.connect(url, protocol: subprotocol, header: header)
client.on :open do
p "opening"
client.send message
end
client.on :message do |message|
puts "Message : #{message.data}"
end
client.on :error do |error|
puts "Erreur : #{error}"
end
Thank you
The text was updated successfully, but these errors were encountered:
@nicohc Sorry. We couldn't help a problem or(and) question for specific product.
If you have problems with this gem not working properly, please share the error and we may be able to help.
And about the graphql query, does the gem allows it ?
This question is difficult to answer to me. Because you can do anything in a block of client.on, send http request, write logfile, and so on, of course send GraphQL request to any host too.
Hello,
Thanks for your nice gem,
I wondering if it's possible to send a graphQL query with the gem :
For the moment , i just receive the welcome and ping message of an external websocket. ref:
Here is my code :
(I also added a header and subprotocol, but not sure if it's the right way to mention it too)
In my controller :
Thank you
The text was updated successfully, but these errors were encountered: