Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update astjson #1026

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/tidwall/gjson v1.17.0
github.com/tidwall/sjson v1.2.5
github.com/vektah/gqlparser/v2 v2.5.14
github.com/wundergraph/astjson v0.0.0-20250102160438-534f686313e6
github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083
go.uber.org/atomic v1.11.0
go.uber.org/goleak v1.3.0
go.uber.org/zap v1.26.0
Expand Down
2 changes: 2 additions & 0 deletions v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ github.com/wundergraph/astjson v0.0.0-20241210135722-15ca0ac078f8 h1:D0Pw/sly2S9
github.com/wundergraph/astjson v0.0.0-20241210135722-15ca0ac078f8/go.mod h1:eOTL6acwctsN4F3b7YE+eE2t8zcJ/doLm9sZzsxxxrE=
github.com/wundergraph/astjson v0.0.0-20250102160438-534f686313e6 h1:VNJdQaqaHtc+02Bl3N9hw0b8sjCSh8ginYYcVKaTBfE=
github.com/wundergraph/astjson v0.0.0-20250102160438-534f686313e6/go.mod h1:eOTL6acwctsN4F3b7YE+eE2t8zcJ/doLm9sZzsxxxrE=
github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083 h1:8/D7f8gKxTBjW+SZK4mhxTTBVpxcqeBgWF1Rfmltbfk=
github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083/go.mod h1:eOTL6acwctsN4F3b7YE+eE2t8zcJ/doLm9sZzsxxxrE=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
Expand Down
15 changes: 15 additions & 0 deletions v2/pkg/engine/resolve/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ func (l *Loader) resolveSingle(item *FetchItem) error {
return nil
}
items := l.selectItemsForPath(item.FetchPath)

switch f := item.Fetch.(type) {
case *SingleFetch:
res := &result{
Expand Down Expand Up @@ -1132,13 +1133,27 @@ func (l *Loader) validatePreFetch(input []byte, info *FetchInfo, res *result) (a
func (l *Loader) loadSingleFetch(ctx context.Context, fetch *SingleFetch, fetchItem *FetchItem, items []*astjson.Value, res *result) error {
res.init(fetch.PostProcessing, fetch.Info)
buf := &bytes.Buffer{}

inputData := l.itemsData(items)
if l.ctx.TracingOptions.Enable {
fetch.Trace = &DataSourceLoadTrace{}
if !l.ctx.TracingOptions.ExcludeRawInputData && inputData != nil {
fetch.Trace.RawInputData, _ = l.compactJSON(inputData.MarshalTo(nil))
}
}

// When we don't have parent data it makes no sense to proceed with next fetches in a sequence
// Right now, it is the case only for the introspection - because introspection uses
// only single fetches.
// Having null means that the previous fetch returned null as data
if len(items) == 1 && items[0].Type() == astjson.TypeNull {
res.fetchSkipped = true
if l.ctx.TracingOptions.Enable {
fetch.Trace.LoadSkipped = true
}
return nil
}

err := fetch.InputTemplate.Render(l.ctx, inputData, buf)
if err != nil {
return l.renderErrorsInvalidInput(fetchItem, res.out)
Expand Down
Loading