Skip to content
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ce23ea5
feat: store field arg maps to variable normalization
dkorittki Jan 26, 2026
1ebb2c3
chore: reduce two functions to one
dkorittki Jan 27, 2026
ea5c630
fix: handle fragments
dkorittki Jan 28, 2026
73a4ac5
fix: support literal values
dkorittki Jan 29, 2026
cd47b12
chore: move mapping to operation normalizer
dkorittki Jan 29, 2026
1b8bddc
Revert "chore: move mapping to operation normalizer"
dkorittki Jan 29, 2026
fdf63d0
fix: expose literal values as astjson object
dkorittki Jan 30, 2026
a85a37b
chore: remove fragment support
dkorittki Feb 2, 2026
546a496
feat: make field arg mapping configurable
dkorittki Feb 2, 2026
e2c713b
Merge branch 'master'
dkorittki Feb 2, 2026
75236fc
Merge branch 'master'
dkorittki Feb 9, 2026
e4c44d3
fix: record mapping for already extracted literals
dkorittki Feb 10, 2026
f629d8d
fix: use valid operation for test
dkorittki Feb 10, 2026
9877606
fix: support inline fragments
dkorittki Feb 11, 2026
94178d4
Merge branch 'master'
dkorittki Feb 12, 2026
15dbb3f
fix: add missing argument after main merge
dkorittki Feb 12, 2026
f7a1c98
chore: preserve original method signature
dkorittki Feb 12, 2026
40a7750
chore: add path string creation tests
dkorittki Feb 12, 2026
0fbb313
chore: add godoc to variable normalizer methods
dkorittki Feb 12, 2026
1166211
chore: use string concat on path build instead of Sprintf
dkorittki Feb 12, 2026
1e8d2a5
Merge branch 'master' into dominik/eng-8826-add-field-argument-mappin…
dkorittki Feb 19, 2026
7d265d7
chore: update godoc/comments + result type name
dkorittki Feb 19, 2026
a43dae9
chore: seperate file for VariablesNormalizer
dkorittki Feb 19, 2026
2462573
chore: Add options type for VariablesNormalizer
dkorittki Feb 19, 2026
0d27f89
fix: fix broken tests
dkorittki Feb 19, 2026
55c1a82
Merge branch 'master' into dominik/eng-8826-add-field-argument-mappin…
dkorittki Feb 23, 2026
f4e3312
Merge branch 'master' into dominik/eng-8826-add-field-argument-mappin…
dkorittki Mar 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions v2/pkg/ast/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (p Path) String() string {
return out
}

func (p Path) DotDelimitedString() string {
func (p Path) DotDelimitedString(useFragmentRefs bool) string {
Comment thread
Noroth marked this conversation as resolved.
Outdated
Comment thread
Noroth marked this conversation as resolved.
Outdated
builder := strings.Builder{}

toGrow := 0
Expand Down Expand Up @@ -160,7 +160,9 @@ func (p Path) DotDelimitedString() string {
}
case InlineFragmentName:
builder.WriteString(InlineFragmentPathPrefix)
builder.WriteString(strconv.Itoa(p[i].FragmentRef))
if useFragmentRefs {
builder.WriteString(strconv.Itoa(p[i].FragmentRef))
}
builder.WriteString(unsafebytes.BytesToString(p[i].FieldName))
}
}
Expand Down
21 changes: 12 additions & 9 deletions v2/pkg/astnormalization/astnormalization.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ package astnormalization

import (
"github.com/wundergraph/graphql-go-tools/v2/pkg/ast"
"github.com/wundergraph/graphql-go-tools/v2/pkg/astnormalization/uploads"
"github.com/wundergraph/graphql-go-tools/v2/pkg/astvisitor"
"github.com/wundergraph/graphql-go-tools/v2/pkg/operationreport"
)
Expand Down Expand Up @@ -245,7 +244,8 @@ func (o *OperationNormalizer) setupOperationWalkers() {

if o.options.extractVariables {
extractVariablesWalker := astvisitor.NewWalkerWithID(8, "ExtractVariables")
extractVariables(&extractVariablesWalker)
// disabling field arg mapping as it's only necessary on the variable normalizer
extractVariables(&extractVariablesWalker, false)
o.operationWalkers = append(o.operationWalkers, walkerStage{
name: "extractVariables",
walker: &extractVariablesWalker,
Expand Down Expand Up @@ -353,7 +353,7 @@ type VariablesNormalizer struct {
variablesExtractionVisitor *variablesExtractionVisitor
}

func NewVariablesNormalizer() *VariablesNormalizer {
func NewVariablesNormalizer(withFieldArgMapping bool) *VariablesNormalizer {
Comment thread
Noroth marked this conversation as resolved.
Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about introducing either an options or config argument?

e.g.

type VariablesNormalizerOptions struct {
  withFieldArgMapping bool
}

WithFieldArgMapping()

or just

type VariablesNormalizerConfig struct {
  WithFieldArgMapping bool
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

// delete unused modifying variables refs,
// so it is safer to run it sequentially with the extraction
thirdDeleteUnused := astvisitor.NewWalkerWithID(8, "DeleteUnusedVariables")
Expand All @@ -367,7 +367,7 @@ func NewVariablesNormalizer() *VariablesNormalizer {
detectVariableUsage(&firstDetectUnused, del)

secondExtract := astvisitor.NewWalkerWithID(8, "ExtractVariables")
variablesExtractionVisitor := extractVariables(&secondExtract)
variablesExtractionVisitor := extractVariables(&secondExtract, withFieldArgMapping)
extractVariablesDefaultValue(&secondExtract)

fourthCoerce := astvisitor.NewWalkerWithID(0, "VariablesCoercion")
Expand All @@ -382,22 +382,25 @@ func NewVariablesNormalizer() *VariablesNormalizer {
}
}

func (v *VariablesNormalizer) NormalizeOperation(operation, definition *ast.Document, report *operationreport.Report) []uploads.UploadPathMapping {
func (v *VariablesNormalizer) NormalizeOperation(operation, definition *ast.Document, report *operationreport.Report) VariablesNormalizerResult {
v.firstDetectUnused.Walk(operation, definition, report)
if report.HasErrors() {
return nil
return VariablesNormalizerResult{}
}
v.secondExtract.Walk(operation, definition, report)
if report.HasErrors() {
return nil
return VariablesNormalizerResult{}
}
v.thirdDeleteUnused.Walk(operation, definition, report)
if report.HasErrors() {
return nil
return VariablesNormalizerResult{}
}
v.fourthCoerce.Walk(operation, definition, report)

return v.variablesExtractionVisitor.uploadsPath
return VariablesNormalizerResult{
UploadsMapping: v.variablesExtractionVisitor.uploadsPath,
FieldArgumentMapping: v.variablesExtractionVisitor.fieldArgumentMapping.result,
}
}

type fragmentCycleVisitor struct {
Expand Down
Loading