~emersion/gqlclient-dev

reorder context to be the first input argument v1 PROPOSED

Kevin Schoon: 1
 reorder context to be the first input argument

 1 files changed, 1 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/gqlclient-dev/patches/41093/mbox | git am -3
Learn more about email & git

[PATCH] reorder context to be the first input argument Export this patch

The canonical usage of context in Go is to pass it in as the first argument
to all functions that accept it. This changes gqlclientgen to generate code
accepting context as the first parameter.
---
 cmd/gqlclientgen/main.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/gqlclientgen/main.go b/cmd/gqlclientgen/main.go
index 541f5e0..8a1e920 100644
--- a/cmd/gqlclientgen/main.go
+++ b/cmd/gqlclientgen/main.go
@@ -302,8 +302,8 @@ func genOp(schema *ast.Schema, op *ast.OperationDefinition) *jen.Statement {

	var stmts, in, out, ret, dataFields []jen.Code

	in = append(in, jen.Id("client").Op("*").Qual(gqlclient, "Client"))
	in = append(in, jen.Id("ctx").Qual("context", "Context"))
	in = append(in, jen.Id("client").Op("*").Qual(gqlclient, "Client"))

	stmts = append(stmts, jen.Id("op").Op(":=").Qual(gqlclient, "NewOperation").Call(jen.Lit(queryStr)))

-- 
2.40.1
Hm, this is a pretty big breaking change, not sure it's worth it...