Skip to content

Commit

Permalink
Go back to using anonmyous structs for marshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucian Jones committed Apr 23, 2024
1 parent 43c6929 commit af1331f
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,37 @@ type executionStepResult struct {
}

func (e *executionStepResult) MarshalJSON() ([]byte, error) {
type toMarshal struct {
return json.Marshal(&struct {
Executed bool
Error error `json:",omitempty"`
TimeTaken string
}
j := toMarshal{
}{
Executed: e.executed,
TimeTaken: e.timeTaken.String(),
Error: e.error,
}
return json.Marshal(&j)
})
}

// MarshalJSON marshals the step the JSON
func (s *QueryPlanStep) MarshalJSON() ([]byte, error) {
ctx := graphql.WithOperationContext(context.Background(), &graphql.OperationContext{
Variables: map[string]interface{}{},
})
type toMarshal struct {
return json.Marshal(&struct {
ServiceURL string
ParentType string
SelectionSet string
InsertionPoint []string
ExecutionStepResult *executionStepResult `json:",omitempty"`
Then []*QueryPlanStep
}
j := toMarshal{
}{
ServiceURL: s.ServiceURL,
ParentType: s.ParentType,
SelectionSet: formatSelectionSetSingleLine(ctx, nil, s.SelectionSet),
InsertionPoint: s.InsertionPoint,
Then: s.Then,
ExecutionStepResult: s.executionResult,
}

return json.Marshal(&j)
})
}

// QueryPlan is a query execution plan
Expand Down

0 comments on commit af1331f

Please sign in to comment.