question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Simpler GraphQL syntax?

See original GitHub issue

Thinking out loud…

What if we went from:

repository() {
	ref(qualifiedName: "${branch}") {
		target {
			... on Commit {
				history(first: 1, path: "${filePath}") {
					nodes {
						oid
						commitDate
					}
				}
			}
		}
	}
}

To:

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:

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:

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? 😂

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sindresorhuscommented, Aug 16, 2021

I find the original syntax more readable.

1reaction
yakov116commented, Aug 11, 2021
  • console.debug for every call in api.v4 when installed locally

Big 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Queries and Mutations - GraphQL
On this page, you'll learn in detail about how to query a GraphQL server. Fields#. At its simplest, GraphQL is about asking for...
Read more >
4 Simple Ways to Call a GraphQL API
1. Using GraphQL IDEs (Apollo Explorer) · 2. Curl · 3. Fetch · 4. Using GraphQL clients (Apollo Client).
Read more >
GraphQL - Query - Tutorialspoint
A GraphQL operation can either be a read or a write operation. A GraphQL query is used to read or fetch values while...
Read more >
GraphQL Queries to fetch data - Hasura
Try out GraphQL Query using GraphiQL. Simple and nested GraphQL query examples with parameters, arguments and variables to fetch data dynamically.
Read more >
GraphQL vs. REST: A GraphQL Tutorial - Toptal
GraphQL is a new way to fetch APIs, an alternative to REST that is more efficient, simpler, and faster to implement.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found