Thinking out loud… What if we went from: ```ts repository() { ref(qualifiedName: "${branch}") { target { ... on Commit { history(first: 1, path: "${filePath}") { nodes { oid commitDate } } } } } } ``` To: ```ts repository() ref(qualifiedName: "${branch}") target ... on Commit history(first: 1, path: "${filePath}") nodes oid commitDate ``` where every line break is a `{` and every missing `}` is appended. Most of our queries are allowed with this syntax. Others can keep using the native syntax. It would be its own helper like: ```ts api.v4(ql` repository() ref(qualifiedName: "${branch}") target ... on Commit history(first: 1, path: "${filePath}") nodes oid commitDate `) ``` and multiple queries can be concatenated as strings too: ```ts api.v4(ql` repository() ref(qualifiedName: "${branch}") target ... on Commit history(first: 1, path: "${filePath}") nodes oid commitDate ` + ql` query2: repository() name `) ``` Thoughts? Worth it? 😂
Activity
yakov116 commentedon Aug 11, 2021
I think that kills the beauty of GraphQL. What I like it most is the way the call is made, that is what the response looks like.
It may take up more "lines" but I think the other way is clearer. JMHO
fregante commentedon Aug 11, 2021
Is that affected though? The only problems I see are:
Almost. The GQL "object" is imprecise:
nodes {}is an array...on Commit {}doesn't appearAs a compromise I thought we could just automatically close any unmatched
{, and that would already make it a little shorter:It'd be cool to make it indentation-based and drop the
{as well, but it's too easy to mix spaces and tabs since the linter does not complain.fregante commentedon Aug 11, 2021
For this we could set up:
console.debugfor every call inapi.v4when installed locallyyakov116 commentedon Aug 11, 2021
Big 👍
fregante commentedon Aug 11, 2021
We can already do that, including the
query {}part. PR welcomesindresorhus commentedon Aug 16, 2021
I find the original syntax more readable.