Skip to content

Using JAQ as an alternative to mustache templates #1321

Closed
@tusharmath

Description

@tusharmath

./jq is an interesting DSL to perform JSON transformations. Embedding JQ can give developers a lot of flexibility when compared to existing mustache templates. The current mustache templates only support accessing values by path, with JQ we should be able to do much more.

Proposal

 type Post {
    id: Int!
    userId: Int!
    title: String
-   user: User @http(path: "/users/{{value.userId}}")
+   user: User @http(path: "/users/{{.value.userId}}")
 }

Technical Requirements

  • Use https://github.com/01mf02/jaq to implement JQ
  • Write benchmarks comparing existing and new implementations
  • Compile and store JQ templates at compile time (Blueprint generation time)

Design

  • Use a JAQ parser to parse a JAQ template and replace the mustache parser with JAQ
  • Implement an evaluator, that can take any JsonLike object and transform it using JAQ.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions