Closed Firobe closed 2 years ago
I played with different ways of generating the needed code. I think of of the easiest way would be to simply annotate a record type, deriver-style, specify information on fields only when strictly needed.
Potentially, queries for all basic types (int, string, float, ...) could be predefined, so that user-defined schemas always have sub-queries among those.
I've got a working PPX deriver generating all needed types from a single record with annotations. Mutations are not managed yet, but subqueries are.
The PPX lives locally for now, and will be merged in Yves-Stan's POC soon.
We discussed with @ylecornec and agreed on the following points:
res
to something like modifier
out
(define it as t res
)t
simple
switch that triggers generate of simple getter fields values. Otherwise, do not generate themresponse_of_json
function should be generated, using only calls to other response_of_json
for subtypesI added the modules for core scalar types as well as some documentation in the gql_types.ml file of the tweag/graphql_experiments
branch.
The new modules are Gql_int
, Gql_string
, etc..
A new version of the PPX is pushed on the tweag/graphql_experiments
branch in src/lib/graphql_ppx
, with a tentative interface for field attributes (see test/example.ml
)
The PPX now generates typ
, correctly rewrites fields
(with type annotations), and overall generates something that compiles.
Next: correctly generate the query
type
Seeing developments on #11081, I'm pausing development on this, since if we can manage to use latest upstream graphql_ppx
, it will subsume this current work as it now generate types.
Closing since it's not clear it's needed anymore. Will reopen if the need arises.
See #10687. A lot of the interface code should be generated, as well as some sugaring for queries. For now, the code for this lives in PRs in https://github.com/ylecornec/graphql_poc.
EDIT: the code now lives in
src/lib/graphql_ppx
in thetweag/graphql_experiments
branch