aantron / dream

Tidy, feature-complete Web framework

Home Page:https://aantron.github.io/dream/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example w-graphql-subscription is broken

aantron opened this issue · comments

Repro:

  1. On master, cd example/w-graphql-subscription.
  2. dune exec ./graphql_subscription.exe
  3. Visit http://localhost:8080/ in a browser.
  4. Click "play" in the GraphiQL IDE that appears.

Result in GraphiQL:

{
  "errors": [
    {
      "message": "Field 'users' is not defined on type 'query'"
    }
  ]
}

By contrast, the query works in the playground, which is using an older version of Dream (and dependencies).

It seems I cannot reproduce the problem:
image

image

Browser: Firefox, Brave
OS: Ubuntu 22.04.2 LTS
Commit: Master HEAD / dbf01b8

Very interesting, thanks! I am still getting this:

gql-broken

Also Ubuntu 22.04.2 LTS, browser Brave.

Could you show what OCaml packages you have installed? I suspect this might be an issue with GQL upstream.

λ opam list

# Packages matching: installed
# Name                  # Installed # Synopsis
alcotest                1.7.0       Alcotest is a lightweight and colourful test framework
angstrom                0.15.0      Parser combinators built for speed and memory-efficiency
astring                 0.8.5       Alternative String module for OCaml
base                    v0.15.1     Full standard library replacement for OCaml
base-bigarray           base
base-bytes              base        Bytes library distributed with the OCaml compiler
base-domains            base
base-nnp                base        Naked pointers prohibited in the OCaml heap
base-threads            base
base-unix               base
base64                  3.5.1       Base64 encoding for OCaml
bigarray-compat         1.1.0       Compatibility library to use Stdlib.Bigarray when possible
bigarray-overlap        0.2.1       Bigarray.overlap
bigstringaf             0.9.1       Bigstring intrinsics and fast blits based on memcpy/memmove
bisect_ppx              2.8.2       Code coverage for OCaml
camlp-streams           5.0.1       The Stream and Genlex libraries for use with Camlp4 and Camlp5
caqti                   1.9.0       Unified interface to relational database libraries
caqti-driver-postgresql 1.9.1       PostgreSQL driver for Caqti based on C bindings
caqti-driver-sqlite3    1.9.0       Sqlite3 driver for Caqti using C bindings
caqti-lwt               1.9.0       Lwt support for Caqti
chrome-trace            3.7.1       Chrome trace event generation library
cmdliner                1.2.0       Declarative definition of command line interfaces for OCaml
conf-libev              4-12        High-performance event loop/event model with lots of features
conf-libssl             4           Virtual package relying on an OpenSSL library system installation
conf-pkg-config         2           Check if pkg-config is installed and create an opam switch local pkg
conf-postgresql         1           Virtual package relying on a PostgreSQL system installation
conf-sqlite3            1           Virtual package relying on an SQLite3 system installation
cppo                    1.6.9       Code preprocessor like cpp for OCaml
crunch                  3.3.1       Convert a filesystem into a static OCaml module
csexp                   1.5.1       Parsing and printing of S-expressions in Canonical form
cstruct                 6.2.0       Access C-like structures directly from OCaml
digestif                1.1.4       Hashes implementations (SHA*, RIPEMD160, BLAKE2* and MD5)
dune                    3.7.1       Fast, portable, and opinionated build system
dune-build-info         3.7.1       Embed build information inside executable
dune-configurator       3.7.1       Helper library for gathering system configuration
dune-rpc                3.6.2       Communicate with dune using rpc
duration                0.2.1       Conversions to various time units
dyn                     3.6.2       Dynamic type
eio                     0.9         Effect-based direct-style IO API for OCaml
eio_linux               0.9         Eio implementation for Linux using io-uring
eio_main                0.9         Effect-based direct-style IO mainloop for OCaml
eio_posix               0.9         Eio implementation for POSIX systems
either                  1.0.0       Compatibility Either module
eqaf                    0.9         Constant-time equal function on string
faraday                 0.8.2       A library for writing fast and memory-efficient serializers
faraday-lwt             0.8.2       Lwt support for Faraday
faraday-lwt-unix        0.8.2       Lwt_unix support for Faraday
fiber                   3.6.2       Structured concurrency library
fix                     20220121    Algorithmic building blocks for memoization, recursion, and more
fmt                     0.9.0       OCaml Format pretty-printer combinators
fpath                   0.7.3       File system paths for OCaml
gen                     1.1         Iterators for OCaml, both restartable and consumable
graphql                 0.14.0      Build GraphQL schemas and execute queries against them
graphql-lwt             0.14.0      Build GraphQL schemas with Lwt support
graphql_parser          0.14.0      Library for parsing GraphQL queries
hmap                    0.8.1       Heterogeneous value maps for OCaml
iomux                   0.3         IO Multiplexer bindings
jane-street-headers     v0.15.0     Jane Street C header files
js_of_ocaml             5.1.1       Compiler from OCaml bytecode to JavaScript
js_of_ocaml-compiler    5.1.1       Compiler from OCaml bytecode to JavaScript
js_of_ocaml-ppx         5.1.1       Compiler from OCaml bytecode to JavaScript
jst-config              v0.15.1     Compile-time configuration for Jane Street libraries
ke                      0.6         Queue implementation
lambda-term             3.3.1       Terminal manipulation library for OCaml
lambdasoup              1.0.0       Easy functional HTML scraping and manipulation with CSS selectors
logs                    0.7.0       Logging infrastructure for OCaml
lwt                     5.6.1       Promises and event-driven I/O
lwt-dllist              1.0.1       Mutable doubly-linked list with Lwt iterators
lwt_eio                 0.2         Run Lwt code within Eio
lwt_ppx                 2.1.0       PPX syntax for Lwt, providing something similar to async/await from 
lwt_react               1.2.0       Helpers for using React with Lwt
lwt_ssl                 1.2.0       OpenSSL binding with concurrent I/O
magic-mime              1.3.0       Map filenames to common MIME types
markup                  1.0.3       Error-recovering functional HTML5 and XML parsers and writers
menhir                  20230415    An LR(1) parser generator
menhirLib               20230415    Runtime support library for parsers generated by Menhir
menhirSdk               20230415    Compile-time library for auxiliary tools related to Menhir
merlin-extend           0.6.1       A protocol to provide custom frontend to Merlin
mew                     0.1.0       Modal editing witch
mew_vi                  0.5.0       Modal editing witch, VI interpreter
mirage-clock            4.2.0       Libraries and module types for portable clocks
mirage-crypto           0.11.1      Simple symmetric cryptography for the modern age
mirage-crypto-rng       0.11.1      A cryptographically secure PRNG
mirage-crypto-rng-eio   0.11.1      Feed the entropy source in an eio-friendly way
mirage-crypto-rng-lwt   0.11.1      A cryptographically secure PRNG
mtime                   2.0.0       Monotonic wall-clock time for OCaml
multipart_form          ~dev        pinned to version ~dev at git+https://github.com/Willenbrink/multipa
multipart_form-eio      ~dev        pinned to version ~dev at git+https://github.com/Willenbrink/multipa
multipart_form-lwt      ~dev        pinned to version ~dev at git+https://github.com/Willenbrink/multipa
ocaml                   5.0.0       The OCaml compiler (virtual package)
ocaml-base-compiler     5.0.0       Official release 5.0.0
ocaml-compiler-libs     v0.12.4     OCaml compiler libraries repackaged
ocaml-config            3           OCaml Switch Configuration
ocaml-lsp-server        1.15.1-5.0  LSP Server for OCaml
ocaml-options-vanilla   1           Ensure that OCaml is compiled with no special options enabled
ocaml-syntax-shims      1.0.0       Backport new syntax to older OCaml versions
ocaml-version           3.6.1       Manipulate, parse and generate OCaml compiler version strings
ocamlbuild              0.14.2      OCamlbuild is a build system with builtin rules to easily build most
ocamlc-loc              3.6.2       Parse ocaml compiler output into structured form
ocamlfind               1.9.6       A library manager for OCaml
ocamlformat             0.25.1      Auto-formatter for OCaml code
ocamlformat-lib         0.25.1      Auto-formatter for OCaml code
ocamlformat-rpc-lib     0.25.1      Auto-formatter for OCaml code (RPC mode)
ocp-browser             1.3.4       pinned to version 1.3.4 at git+https://github.com/OCamlPro/ocp-index
ocp-indent              1.8.1       A simple tool to indent OCaml programs
ocp-index               1.3.4       Lightweight completion and documentation browsing for OCaml librarie
ocplib-endian           1.2         Optimised functions to read and write int16/32/64 from strings and b
octavius                1.2.2       Ocamldoc comment syntax parser
omd                     1.3.2       A Markdown frontend in pure OCaml
optint                  0.3.0       Efficient integer types on 64-bit architectures
ordering                3.6.2       Element ordering
pecu                    0.6         Encoder/Decoder of Quoted-Printable (RFC2045 & RFC2047)
postgresql              5.0.0       Bindings to the PostgreSQL library
pp                      1.1.2       Pretty-printing library
ppx_assert              v0.15.0     Assert-like extension nodes that raise useful errors on failure
ppx_base                v0.15.0     Base set of ppx rewriters
ppx_cold                v0.15.0     Expands [@cold] into [@inline never][@specialise never][@local never
ppx_compare             v0.15.0     Generation of comparison functions from types
ppx_derivers            1.2.1       Shared [@@deriving] plugin registry
ppx_enumerate           v0.15.0     Generate a list containing all values of a finite type
ppx_expect              v0.15.1     Cram like framework for OCaml
ppx_hash                v0.15.0     A ppx rewriter that generates hash functions from type expressions a
ppx_here                v0.15.0     Expands [%here] into its location
ppx_inline_test         v0.15.1     Syntax extension for writing in-line tests in ocaml code
ppx_js_style            v0.15.0     Code style checker for Jane Street Packages
ppx_optcomp             v0.15.0     Optional compilation for OCaml
ppx_sexp_conv           v0.15.1     [@@deriving] plugin to generate S-expression conversion functions
ppx_yojson_conv         v0.15.1     [@@deriving] plugin to generate Yojson conversion functions
ppx_yojson_conv_lib     v0.15.0     Runtime lib for ppx_yojson_conv
ppxlib                  0.27.0      Standard library for ppx rewriters
prettym                 0.0.3       An memory-bounded encoder according to RFC 822
psq                     0.2.1       Functional Priority Search Queues
ptime                   1.1.0       POSIX time for OCaml
re                      1.10.4      RE is a regular expression library for OCaml
react                   1.2.2       Declarative events and signals for OCaml
reason                  3.8.2       Reason: Syntax & Toolchain for OCaml
result                  1.5         Compatibility Result module
rresult                 0.7.0       Result value combinators for OCaml
sedlex                  3.1         An OCaml lexer generator for Unicode
seq                     base        Compatibility package for OCaml's standard iterator type starting fr
sexplib0                v0.15.1     Library containing the definition of S-expressions and some base con
spawn                   v0.15.1     Spawning sub-processes
sqlite3                 5.1.0       SQLite3 bindings for OCaml
ssl                     0.5.13      Bindings for OpenSSL
stdio                   v0.15.0     Standard IO library for OCaml
stdlib-shims            0.3.0       Backport some of the new stdlib features to older compiler
stdune                  3.6.2       Dune's unstable standard library
stringext               1.6.0       Extra string functions for OCaml
time_now                v0.15.0     Reports the current time
topkg                   1.0.7       The transitory OCaml software packager
trie                    1.0.0       Strict impure trie tree
tyxml                   4.5.0       A library for building correct HTML and SVG documents
uchar                   0.0.2       Compatibility library for OCaml's Uchar module
unstrctrd               0.3         Unstructured parser
uri                     4.2.0       An RFC3986 URI/URL parsing library
uring                   0.5         OCaml bindings for Linux io_uring
uucp                    15.0.0      Unicode character properties for OCaml
uuseg                   15.0.0      Unicode text segmentation for OCaml
uutf                    1.0.3       Non-blocking streaming Unicode codec for OCaml
xdg                     3.7.1       XDG Base Directory Specification
yojson                  2.0.2       Yojson is an optimized parsing and printing library for the JSON for
zed                     3.2.1       Abstract engine for text edition in OCaml

Also, I did try this specifically on dbf01b8 for good measure, but it's broken on all recent commits in master for me.

I had a switch with 4.14 compiler and I saw you're using OCaml 5 so I created a clean switch with OCaml 5.
My list looks a bit different. I installed the deps as documented:

opam install --deps-only ./dream.opam --with-test

This is the result

# Packages matching: installed
# Name                  # Installed  # Synopsis
alcotest                1.7.0        Alcotest is a lightweight and colourful test framework
angstrom                0.15.0       Parser combinators built for speed and memory-efficiency
astring                 0.8.5        Alternative String module for OCaml
base                    v0.15.1      Full standard library replacement for OCaml
base-bigarray           base
base-bytes              base         Bytes library distributed with the OCaml compiler
base-domains            base
base-nnp                base         Naked pointers prohibited in the OCaml heap
base-threads            base
base-unix               base
base64                  3.5.1        Base64 encoding for OCaml
bigarray-compat         1.1.0        Compatibility library to use Stdlib.Bigarray when possible
bigarray-overlap        0.2.1        Bigarray.overlap
bigstringaf             0.9.1        Bigstring intrinsics and fast blits based on memcpy/memmove
bisect_ppx              2.8.2        Code coverage for OCaml
camlp-streams           5.0.1        The Stream and Genlex libraries for use with Camlp4 and Camlp5
caqti                   1.9.0        Unified interface to relational database libraries
caqti-driver-postgresql 1.9.1        PostgreSQL driver for Caqti based on C bindings
caqti-driver-sqlite3    1.9.0        Sqlite3 driver for Caqti using C bindings
caqti-lwt               1.9.0        Lwt support for Caqti
cmdliner                1.2.0        Declarative definition of command line interfaces for OCaml
conf-libev              4-12         High-performance event loop/event model with lots of features
conf-libssl             4            Virtual package relying on an OpenSSL library system installation
conf-pkg-config         2            Check if pkg-config is installed and create an opam switch local pkgconfig folder
conf-postgresql         1            Virtual package relying on a PostgreSQL system installation
conf-sqlite3            1            Virtual package relying on an SQLite3 system installation
cppo                    1.6.9        Code preprocessor like cpp for OCaml
crunch                  3.3.1        Convert a filesystem into a static OCaml module
csexp                   1.5.2        Parsing and printing of S-expressions in Canonical form
cstruct                 6.2.0        Access C-like structures directly from OCaml
digestif                1.1.4        Hashes implementations (SHA*, RIPEMD160, BLAKE2* and MD5)
dream-httpaf            1.0.0~alpha2 Internal: shared http/af stack for Dream (server) and Hyper (client)
dream-pure              1.0.0~alpha2 Internal: shared HTTP types for Dream (server) and Hyper (client)
dune                    3.7.1        Fast, portable, and opinionated build system
dune-configurator       3.7.1        Helper library for gathering system configuration
duration                0.2.1        Conversions to various time units
eqaf                    0.9          Constant-time equal function on string
faraday                 0.8.2        A library for writing fast and memory-efficient serializers
faraday-lwt             0.8.2        Lwt support for Faraday
faraday-lwt-unix        0.8.2        Lwt_unix support for Faraday
fix                     20220121     Algorithmic building blocks for memoization, recursion, and more
fmt                     0.9.0        OCaml Format pretty-printer combinators
gen                     1.1          Iterators for OCaml, both restartable and consumable
graphql                 0.14.0       Build GraphQL schemas and execute queries against them
graphql-lwt             0.14.0       Build GraphQL schemas with Lwt support
graphql_parser          0.14.0       Library for parsing GraphQL queries
hmap                    0.8.1        Heterogeneous value maps for OCaml
jane-street-headers     v0.15.0      Jane Street C header files
js_of_ocaml             5.1.1        Compiler from OCaml bytecode to JavaScript
js_of_ocaml-compiler    5.1.1        Compiler from OCaml bytecode to JavaScript
js_of_ocaml-ppx         5.1.1        Compiler from OCaml bytecode to JavaScript
jst-config              v0.15.1      Compile-time configuration for Jane Street libraries
ke                      0.6          Queue implementation
lambdasoup              1.0.0        Easy functional HTML scraping and manipulation with CSS selectors
logs                    0.7.0        Logging infrastructure for OCaml
lwt                     5.6.1        Promises and event-driven I/O
lwt_ppx                 2.1.0        PPX syntax for Lwt, providing something similar to async/await from JavaScript
lwt_ssl                 1.2.0        OpenSSL binding with concurrent I/O
magic-mime              1.3.0        Map filenames to common MIME types
markup                  1.0.3        Error-recovering functional HTML5 and XML parsers and writers
menhir                  20230415     An LR(1) parser generator
menhirLib               20230415     Runtime support library for parsers generated by Menhir
menhirSdk               20230415     Compile-time library for auxiliary tools related to Menhir
merlin-extend           0.6.1        A protocol to provide custom frontend to Merlin
mirage-clock            4.2.0        Libraries and module types for portable clocks
mirage-crypto           0.11.1       Simple symmetric cryptography for the modern age
mirage-crypto-rng       0.11.1       A cryptographically secure PRNG
mirage-crypto-rng-lwt   0.11.1       A cryptographically secure PRNG
mtime                   2.0.0        Monotonic wall-clock time for OCaml
multipart_form          0.5.0        Multipart-form: RFC2183, RFC2388 & RFC7578
multipart_form-lwt      0.5.0        Multipart-form: RFC2183, RFC2388 & RFC7578
ocaml                   5.0.0        The OCaml compiler (virtual package)
ocaml-base-compiler     5.0.0        Official release 5.0.0
ocaml-compiler-libs     v0.12.4      OCaml compiler libraries repackaged
ocaml-config            3            OCaml Switch Configuration
ocaml-options-vanilla   1            Ensure that OCaml is compiled with no special options enabled
ocaml-syntax-shims      1.0.0        Backport new syntax to older OCaml versions
ocamlbuild              0.14.2       OCamlbuild is a build system with builtin rules to easily build most OCaml projects
ocamlfind               1.9.6        A library manager for OCaml
ocplib-endian           1.2          Optimised functions to read and write int16/32/64 from strings and bigarrays
octavius                1.2.2        Ocamldoc comment syntax parser
pecu                    0.6          Encoder/Decoder of Quoted-Printable (RFC2045 & RFC2047)
postgresql              5.0.0        Bindings to the PostgreSQL library
ppx_assert              v0.15.0      Assert-like extension nodes that raise useful errors on failure
ppx_base                v0.15.0      Base set of ppx rewriters
ppx_cold                v0.15.0      Expands [@cold] into [@inline never][@specialise never][@local never]
ppx_compare             v0.15.0      Generation of comparison functions from types
ppx_derivers            1.2.1        Shared [@@deriving] plugin registry
ppx_enumerate           v0.15.0      Generate a list containing all values of a finite type
ppx_expect              v0.15.1      Cram like framework for OCaml
ppx_hash                v0.15.0      A ppx rewriter that generates hash functions from type expressions and definitions
ppx_here                v0.15.0      Expands [%here] into its location
ppx_inline_test         v0.15.1      Syntax extension for writing in-line tests in ocaml code
ppx_js_style            v0.15.0      Code style checker for Jane Street Packages
ppx_optcomp             v0.15.0      Optional compilation for OCaml
ppx_sexp_conv           v0.15.1      [@@deriving] plugin to generate S-expression conversion functions
ppx_yojson_conv         v0.15.1      [@@deriving] plugin to generate Yojson conversion functions
ppx_yojson_conv_lib     v0.15.0      Runtime lib for ppx_yojson_conv
ppxlib                  0.27.0       Standard library for ppx rewriters
prettym                 0.0.3        An memory-bounded encoder according to RFC 822
psq                     0.2.1        Functional Priority Search Queues
ptime                   1.1.0        POSIX time for OCaml
re                      1.10.4       RE is a regular expression library for OCaml
reason                  3.8.2        Reason: Syntax & Toolchain for OCaml
result                  1.5          Compatibility Result module
rresult                 0.7.0        Result value combinators for OCaml
sedlex                  3.1          An OCaml lexer generator for Unicode
seq                     base         Compatibility package for OCaml's standard iterator type starting from 4.07.
sexplib0                v0.15.1      Library containing the definition of S-expressions and some base converters
sqlite3                 5.1.0        SQLite3 bindings for OCaml
ssl                     0.5.13       Bindings for OpenSSL
stdio                   v0.15.0      Standard IO library for OCaml
stdlib-shims            0.3.0        Backport some of the new stdlib features to older compiler
stringext               1.6.0        Extra string functions for OCaml
time_now                v0.15.0      Reports the current time
topkg                   1.0.7        The transitory OCaml software packager
tyxml                   4.5.0        A library for building correct HTML and SVG documents
uchar                   0.0.2        Compatibility library for OCaml's Uchar module
unstrctrd               0.3          Unstructured parser
uri                     4.2.0        An RFC3986 URI/URL parsing library
uutf                    1.0.3        Non-blocking streaming Unicode codec for OCaml
yojson                  2.0.2        Yojson is an optimized parsing and printing library for the JSON format

Additionally, I made sure not to run any esy commands in w-graphql-subscription. Right after deps installation,
I navigated into the dir and ran dune exec ./graphql_subscription.exe. Still works as expected.

Thanks @laaksonel! My query was different. I assumed that this example was self-contained, but it looks like the query was being taken from local storage from example i-graphql. Ideally, the GraphiQL served by Dream's examples wouldn't cache the query. However, that's also the same GraphiQL that is built into Dream for users' development needs.