-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using JAQ as an alternative to mustache templates #1321
Comments
/bounty 600 |
💎 $600 bounty created by tailcallhq 🙏 Thank you for contributing to tailcallhq/tailcall!.
|
/attempt 1321 |
@ssddOnTop: The Tailcall Inc. team prefers to assign a single contributor to the issue rather than let anyone attempt it right away. We recommend waiting for a confirmation from a member before getting started. |
@tusharmath could you assign this to me? |
Deprioritizing this for now. |
@tusharmath can I start working on this? |
Please go ahead |
/attempt #1321
|
@tusharmath there is an issue with the way jaq operates and jsonlike's current capabilities. jaq needs to know about the type of data it is given. But jsonlike does not currently have a way of directly supplying this information. The best jsonlike can do is try all of the as_ functions to see which one returns correctly. Unless jsonlike is updated to be able to provide type data there is no practical way of getting jaq to work on jsonlike data. |
@tusharmath can I change the design of the jsonlike trait to support jaq? |
@digital-phoenix sure you can change the design of jsonlike but try to keep the changes minimal also it should not break other functionalities, like wasm, grpc etc. |
@amitksingh1490 the simplest thing to do would be to serialize the jsonlike trait. But that would lose the advantage of lazy evaluation. I'll see if adding a gettype function (a function that returns the current type) to jsonlike is sufficient for working with JAQ. |
@digital-phoenix: Reminder that in 1 days the bounty will become up for grabs, so please submit a pull request before then 🙏 |
@amitksingh1490 Unless I'm missing an opportunity to add indirection I think JAQ currently needs object to be fully realized as a map of string value pairs. I could add functionality to JAQ to support lazy evaluation but that's probably beyond the scope of this issue. For now can I add an as_map function to convert a jsonlike trait to a map of key value pairs? |
The bounty is up for grabs! Everyone is welcome to |
@tusharmath can I start working on this? |
Please do. |
Anyone still trying to get this finished? Or are the goals of lazily evaluating types implementing |
I performed some benchmarks after implementing a new config used: schema
@server(port: 8000)
@upstream(baseURL: "http://jsonplaceholder.typicode.com") {
query: Query
}
type Query @cache(maxAge: 60000) {
posts: [Post] @http(path: "/posts")
users: [User] @http(path: "/users")
user(id: Int!): User @http(path: "/users/{{.args.id}}")
}
type User {
id: Int!
name: String!
username: String!
email: String!
phone: String
website: String
}
type Post {
id: Int!
userId: Int!
title: String!
body: String!
curId: String! @jq(query: ".id")
} wrk.lua: wrk.method = "POST"
wrk.body = '{"operationName":null,"variables":{},"query":"{posts { curId }}"}' -- change curId to id to compare b/w jq impl and currnet impl
wrk.headers["Connection"] = "keep-alive"
wrk.headers["Content-Type"] = "application/json"
wrk.timeout = 10 command: according to 01mf02/jaq#173 (comment) so I created a custom wrapper for async_graphql::Value (as it's used in majority of our codebase) as I performed benchmarks on:
here are the benchmarks:
Conclusion: In my previous pr (#1801) I performed benchmark to see the difference b/w current Mustache implementation and JQ, it turns out that is is (All these tests were performed on M1 max macbook) |
Thanks @ssddOnTop for providing details about the benchmarks. I think this should close the chapter on JQ. Overall I see two problems:
I will close the JQ integration for now. Instead, we will leverage JS and JS only for doing anything custom. |
./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
Technical Requirements
Design
JsonLike
object and transform it using JAQ.The text was updated successfully, but these errors were encountered: