Skip to content

Commit 2a92e4b

Browse files
authored
Merge branch 'master' into fix/interface-objects
2 parents 9fabb21 + d49a6f3 commit 2a92e4b

4 files changed

Lines changed: 19 additions & 3 deletions

File tree

release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"v2": "2.0.0-rc.148",
2+
"v2": "2.0.0-rc.149",
33
"execution": "1.2.0"
44
}

v2/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [2.0.0-rc.149](https://github.com/wundergraph/graphql-go-tools/compare/v2.0.0-rc.148...v2.0.0-rc.149) (2025-02-07)
4+
5+
6+
### Bug Fixes
7+
8+
* extracting object input with optional variable values ([#1056](https://github.com/wundergraph/graphql-go-tools/issues/1056)) ([3325eac](https://github.com/wundergraph/graphql-go-tools/commit/3325eac3f1dc70069e8057972bf1da5f7324402a))
9+
310
## [2.0.0-rc.148](https://github.com/wundergraph/graphql-go-tools/compare/v2.0.0-rc.147...v2.0.0-rc.148) (2025-02-07)
411

512

v2/pkg/ast/ast_value.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,22 @@ func (d *Document) writeJSONValue(buf *bytes.Buffer, value Value) error {
175175
case ValueKindObject:
176176
buf.WriteByte(literal.LBRACE_BYTE)
177177
for ii, ref := range d.ObjectValues[value.Ref].Refs {
178+
objFieldValue := d.ObjectFieldValue(ref)
179+
if objFieldValue.Kind == ValueKindVariable {
180+
variableName := d.Input.ByteSliceString(d.VariableValues[objFieldValue.Ref].Name)
181+
_, dataType, _, _ := jsonparser.Get(d.Input.Variables, variableName)
182+
if dataType == jsonparser.NotExist {
183+
continue
184+
}
185+
}
186+
178187
if ii > 0 {
179188
buf.WriteByte(literal.COMMA_BYTE)
180189
}
181190
fieldNameBytes := d.ObjectFieldNameBytes(ref)
182191
buf.Write(quotes.WrapBytes(fieldNameBytes))
183192
buf.WriteByte(literal.COLON_BYTE)
184-
if err := d.writeJSONValue(buf, d.ObjectFieldValue(ref)); err != nil {
193+
if err := d.writeJSONValue(buf, objFieldValue); err != nil {
185194
return err
186195
}
187196
}

v2/pkg/astnormalization/astnormalization_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ func TestVariablesNormalizer(t *testing.T) {
856856

857857
out := unsafeprinter.Print(&operationDocument)
858858
assert.Equal(t, `mutation HttpBinPost($bar: String!, $a: HttpBinPostInput){httpBinPost(input: $a){headers {userAgent} data {foo}}}`, out)
859-
require.Equal(t, `{"a":{"foo":"bar","bar":null}}`, string(operationDocument.Input.Variables))
859+
require.Equal(t, `{"a":{"foo":"bar"}}`, string(operationDocument.Input.Variables))
860860
}
861861

862862
func BenchmarkAstNormalization(b *testing.B) {

0 commit comments

Comments
 (0)