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

fix: issue #65: type of ResolveInfo.RootValue should be interface{} #608

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 examples/modify-context/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func main() {
result := graphql.Do(graphql.Params{
Context: ctx,
RequestString: "{ users { id } }",
RootObject: rootObject,
Root: rootObject,
Schema: schema,
})
b, err := json.Marshal(result)
Expand Down
4 changes: 2 additions & 2 deletions executor_resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestExecutesResolveFunction_DefaultFunctionAccessesProperties(t *testing.T)
result := graphql.Do(graphql.Params{
Schema: schema,
RequestString: `{ test }`,
RootObject: source,
Root: source,
})
if !reflect.DeepEqual(expected, result.Data) {
t.Fatalf("Unexpected result, Diff: %v", testutil.Diff(expected, result.Data))
Expand All @@ -60,7 +60,7 @@ func TestExecutesResolveFunction_DefaultFunctionCallsMethods(t *testing.T) {
result := graphql.Do(graphql.Params{
Schema: schema,
RequestString: `{ test }`,
RootObject: source,
Root: source,
})
if !reflect.DeepEqual(expected, result.Data) {
t.Fatalf("Unexpected result, Diff: %v", testutil.Diff(expected, result.Data))
Expand Down
13 changes: 12 additions & 1 deletion graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ type Params struct {

// The value provided as the first argument to resolver functions on the top
// level type (e.g. the query object type).
//
// Deprecated: use the Root field instead.
RootObject map[string]interface{}

// The value provided as the first argument to resolver functions on the top
// level type (e.g. the query object type).
Root interface{}

// A mapping of variable name to runtime value to use for all variables
// defined in the requestString.
VariableValues map[string]interface{}
Expand Down Expand Up @@ -105,9 +111,14 @@ func Do(p Params) *Result {
}
}

root := p.Root
if root == nil {
root = p.RootObject
}

return Execute(ExecuteParams{
Schema: p.Schema,
Root: p.RootObject,
Root: root,
AST: AST,
OperationName: p.OperationName,
Args: p.VariableValues,
Expand Down