nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: jensneuse/graphql-go-tools
Pull request #76 (2019-05-10 23:11:52)

Parser dropping function signature
For #75 


Patch:
diff --git a/pkg/printer/printer.go b/pkg/printer/printer.go
index c0eba9b1..44ff4aed 100644
--- a/pkg/printer/printer.go
+++ b/pkg/printer/printer.go
@@ -453,6 +453,9 @@ func (p *Printer) printOperation(operation document.OperationDefinition) {
 	p.printOperationType(operation.OperationType, hasName)
 	if hasName {
 		p.write(p.p.ByteSlice(operation.Name))
+		if len(operation.VariableDefinitions) > 0 {
+			p.printVariableDefinitions(operation.VariableDefinitions)
+		}
 		p.write(literal.SPACE)
 	}
 	if operation.DirectiveSet != -1 {
@@ -673,3 +676,32 @@ func (p *Printer) printListValue(ref int) {
 
 	p.write(literal.SQUAREBRACKETCLOSE)
 }
+
+func (p *Printer) printVariableDefinition(definition document.VariableDefinition) {
+	p.write(literal.DOLLAR)
+	p.write(p.p.ByteSlice(definition.Variable))
+	p.write(literal.COLON)
+	p.PrintType(definition.Type)
+}
+
+func (p *Printer) printVariableDefinitions(definitions []int) {
+
+	variableDefinitions := p.l.VariableDefinitionIterator(definitions)
+
+	p.write(literal.BRACKETOPEN)
+
+	prependSpaceBeforeNext := false
+
+	for variableDefinitions.Next() {
+		if prependSpaceBeforeNext {
+			p.write(literal.SPACE)
+		}
+
+		variable, _ := variableDefinitions.Value()
+		p.printVariableDefinition(variable)
+
+		prependSpaceBeforeNext = true
+	}
+
+	p.write(literal.BRACKETCLOSE)
+}


Test patch:
diff --git a/pkg/printer/printer_test.go b/pkg/printer/printer_test.go
index a534302e..94a87cb9 100644
--- a/pkg/printer/printer_test.go
+++ b/pkg/printer/printer_test.go
@@ -141,6 +141,12 @@ func TestPrinter(t *testing.T) {
 	t.Run("multiple directive on field", func(t *testing.T) {
 		run("{foo @bar(baz:\"bat\") @foo2}")
 	})
+	t.Run("query with single argument", func(t *testing.T) {
+		run("query Anthem($name:String!) {name id}")
+	})
+	t.Run("query with multiple arguments", func(t *testing.T) {
+		run("query Anthem($name:String! $id:Int) {name id description}")
+	})
 }
 
 func TestPrinter_Regression(t *testing.T) {