Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement connection handling for graphql-transport-ws sub protocol. #126

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ resources/graphiql/
.classpath
.cpcache
.clj-kondo
.lsp
.settings
.vscode
1 change: 1 addition & 0 deletions build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"es6-promise/dist/es6-promise.auto.min.js" "es6-promise.auto.min.js"
"react/umd/react.production.min.js" "react.min.js"
"react-dom/umd/react-dom.production.min.js" "react-dom.min.js"
"graphql-ws/umd/graphql-ws.min.js" "graphql-ws.min.js"
"subscriptions-transport-ws/browser/client.js" "subscriptions-transport-ws-browser-client.js"})

(defn prep
Expand Down
10 changes: 8 additions & 2 deletions dev-resources/com/walmartlabs/lacinia/test_utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@
([]
(subscriptions-fixture ws-uri))
([uri]
(subscriptions-fixture uri {}))
([uri {:keys [subprotocols]}]
(fn [f]
(log/debug :reason ::test-start :uri uri)
(let [messages-ch (chan 10)
Expand All @@ -211,9 +213,13 @@
(log/debug :reason ::receive :message message-text)
(put! messages-ch (cheshire/parse-string message-text true)))
:on-connect (fn [_] (log/debug :reason ::connected))
:on-close #(log/debug :reason ::closed :code %1 :message %2)
:on-close (fn [code message]
(log/debug :reason ::closed :code code :message code)
(put! messages-ch {:code code
:message message}))
:on-error #(log/error :reason ::unexpected-error
:exception %))]
:exception %)
:subprotocols subprotocols)]

(binding [*session* session
;; New messages channel on each test as well, to ensure failed tests don't cause
Expand Down
2 changes: 1 addition & 1 deletion dev-resources/demo-schema.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{:tick
{:description "A subscription response."
:fields {:time_ms {:type String
:description "Time when tick is emittied (as string-ified long milliseconds since epoch)."
:description "Time when tick is emitted (as string-field long milliseconds since epoch)."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, one was a typo, but I meant "string-ified" as the difference between 42 and "42". The latter is string-ified, i.e., a numeric string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ified wasn't really a typo, I was trying to express that time was a numeric string, not a number.

:resolve :tick/time-ms}
:count {:type Int
:descripion "Countdown on number of ticks after this one (e.g., 0 is the last tick before the subscription closes)."}}}}
Expand Down
1 change: 1 addition & 0 deletions dev-resources/demo.clj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
:ide-path "/ui"
:ide-headers {"apikey" "mean mister mustard"}
:ide-connection-params {:moon-base :alpha}
:ide-use-legacy-ws-client false
:subscriptions true
:subscriptions-path "/ws"})
http/create-server
Expand Down
2 changes: 2 additions & 0 deletions dev-resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<logger name="com.walmartlabs.lacinia" level="warn"/>
<logger name="com.walmartlabs.lacinia.test-utils" level="warn"/>

<logger name="com.walmartlabs.lacinia.pedestal.subscriptions" level="warn"/>

<logger name="org.eclipse.jetty.websocket" level="warn"/>
<logger name="clj-antlr.common" level="error"/>

Expand Down
Loading