Skip to content

Commit

Permalink
Merge pull request #206 from zshipko/fix-websocket-conflict
Browse files Browse the repository at this point in the history
Fix websocket conflict, update deprecated Fmt functions
  • Loading branch information
andreas authored Apr 21, 2022
2 parents 7e55d21 + b1d3528 commit 520ccd4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion graphql-async/test/async_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let test_query schema ctx query expected =
| Ok (`Stream stream) ->
Async_kernel.Pipe.to_list stream >>| fun lst ->
`List
Core_kernel.(
Core.(
List.map lst ~f:(fun x -> Option.value_exn (Result.ok x)))
| Error err -> Async_kernel.return err)
>>| fun result ->
Expand Down
2 changes: 1 addition & 1 deletion graphql-cohttp/src/graphql_cohttp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ module Make
(Io : Cohttp.S.IO with type 'a t = 'a Schema.Io.t)
(Body : HttpBody with type +'a io := 'a Schema.Io.t) =
struct
module Ws = Websocket.Connection.Make (Io)
module Ws = Graphql_websocket.Connection.Make (Io)
module Websocket_transport = Websocket_handler.Make (Schema.Io) (Ws)

let ( >>= ) = Io.( >>= )
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions graphql-cohttp/src/websocket_handler.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Make
(IO : Graphql_intf.IO)
(Ws : Websocket.Connection.S with type 'a IO.t = 'a IO.t) =
(Ws : Graphql_websocket.Connection.S with type 'a IO.t = 'a IO.t) =
struct
module Json = Yojson.Basic.Util

Expand Down Expand Up @@ -61,7 +61,7 @@ struct

(* | Gql_connection_keep_alive -> "ka" *)

let create_message ?(opcode = Websocket.Frame.Opcode.Text) ?id
let create_message ?(opcode = Graphql_websocket.Frame.Opcode.Text) ?id
?(payload = `Null) typ =
let frame_payload =
`Assoc
Expand All @@ -72,13 +72,13 @@ struct
]
in
let content = Yojson.Basic.to_string frame_payload in
Websocket.Frame.create ~opcode ~content ()
Graphql_websocket.Frame.create ~opcode ~content ()

let handle_frame t ~execute_query frame =
match frame.Websocket.Frame.opcode with
match frame.Graphql_websocket.Frame.opcode with
| Ping | Pong | Close | Ctrl _ | Nonctrl _ -> IO.return ()
| Continuation | Text | Binary -> (
let json = Yojson.Basic.from_string frame.Websocket.Frame.content in
let json = Yojson.Basic.from_string frame.Graphql_websocket.Frame.content in
match client_message_of_payload json with
| Ok Gql_connection_init ->
Ws.send t.conn (create_message Gql_connection_ack)
Expand Down Expand Up @@ -106,7 +106,7 @@ struct
| Ok Gql_connection_terminate ->
Hashtbl.iter (fun _id close -> close ()) t.subscriptions;
Ws.send t.conn
(create_message ~opcode:Websocket.Frame.Opcode.Close
(create_message ~opcode:Graphql_websocket.Frame.Opcode.Close
Gql_connection_error)
| Error msg ->
let id = Json.(json |> member "id" |> to_string) in
Expand Down
2 changes: 1 addition & 1 deletion graphql_parser/src/ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ module Pp = struct

and selection_set fmt =
omit_empty_list
Fmt.(braces (hvbox ~indent:2 (prefix cut (list pp_selection))))
Fmt.(braces (hvbox ~indent:2 (cut ++ (list pp_selection))))
fmt

let rec pp_typ fmt = function
Expand Down

0 comments on commit 520ccd4

Please sign in to comment.