MinaProtocol / mina

Mina is a cryptocurrency protocol with a constant size blockchain, improving scaling while maintaining decentralization and security.
https://minaprotocol.com
Apache License 2.0
1.99k stars 528 forks source link

Develop a generative PPX alongside the GraphQL PoC #10814

Closed Firobe closed 2 years ago

Firobe commented 2 years ago

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 the tweag/graphql_experiments branch

Firobe commented 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.

Firobe commented 2 years ago

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.

Firobe commented 2 years ago

We discussed with @ylecornec and agreed on the following points:

ylecornec commented 2 years ago

I 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..

Firobe commented 2 years ago

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)

Firobe commented 2 years ago

The PPX now generates typ, correctly rewrites fields (with type annotations), and overall generates something that compiles. Next: correctly generate the query type

Firobe commented 2 years ago

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.

Firobe commented 2 years ago

Closing since it's not clear it's needed anymore. Will reopen if the need arises.