diff --git a/benchmarks/Utils/SchemaGenerator.php b/benchmarks/Utils/SchemaGenerator.php
index 495ad8f..1dce8f6 100644
--- a/benchmarks/Utils/SchemaGenerator.php
+++ b/benchmarks/Utils/SchemaGenerator.php
@@ -152,7 +152,7 @@ class SchemaGenerator
];
}
- public function resolveField($rootValue, $args, $context, $resolveInfo)
+ public function resolveField($objectValue, $args, $context, $resolveInfo)
{
return $resolveInfo->fieldName . '-value';
}
diff --git a/docs/type-system/enum-types.md b/docs/type-system/enum-types.md
index ea62c2b..bfab3a5 100644
--- a/docs/type-system/enum-types.md
+++ b/docs/type-system/enum-types.md
@@ -158,7 +158,7 @@ $heroType = new ObjectType([
'args' => [
'episode' => Type::nonNull($enumType)
],
- 'resolve' => function($rootValue, $args) {
+ 'resolve' => function($hero, $args) {
return $args['episode'] === 5 ? true : false;
}
]
diff --git a/docs/type-system/object-types.md b/docs/type-system/object-types.md
index c12595a..0b950c0 100644
--- a/docs/type-system/object-types.md
+++ b/docs/type-system/object-types.md
@@ -69,7 +69,7 @@ name | `string` | **Required.** Unique name of this object type within S
fields | `array` or `callable` | **Required**. An array describing object fields or callable returning such an array. See [Fields](#field-definitions) section below for expected structure of each array entry. See also the section on [Circular types](#recurring-and-circular-types) for an explanation of when to use callable for this option.
description | `string` | Plain-text description of this type for clients (e.g. used by [GraphiQL](https://github.com/graphql/graphiql) for auto-generated documentation)
interfaces | `array` or `callable` | List of interfaces implemented by this type or callable returning such a list. See [Interface Types](interfaces.md) for details. See also the section on [Circular types](#recurring-and-circular-types) for an explanation of when to use callable for this option.
-isTypeOf | `callable` | **function($rootValue, $context, [ResolveInfo](../reference.md#graphqltypedefinitionresolveinfo) $info)**
Expected to return **true** if **$value** qualifies for this type (see section about [Abstract Type Resolution](interfaces.md#interface-role-in-data-fetching) for explanation).
+isTypeOf | `callable` | **function($value, $context, [ResolveInfo](../reference.md#graphqltypedefinitionresolveinfo) $info)**
Expected to return **true** if **$value** qualifies for this type (see section about [Abstract Type Resolution](interfaces.md#interface-role-in-data-fetching) for explanation).
resolveField | `callable` | **function($value, $args, $context, [ResolveInfo](../reference.md#graphqltypedefinitionresolveinfo) $info)**
Given the **$value** of this type, it is expected to return value for a field defined in **$info->fieldName**. A good place to define a type-specific strategy for field resolution. See section on [Data Fetching](../data-fetching.md) for details.
# Field configuration options
@@ -80,7 +80,7 @@ Option | Type | Notes
name | `string` | **Required.** Name of the field. When not set - inferred from **fields** array key (read about [shorthand field definition](#shorthand-field-definitions) below)
type | `Type` | **Required.** An instance of internal or custom type. Note: type must be represented by a single instance within one schema (see also [Type Registry](index.md#type-registry))
args | `array` | An array of possible type arguments. Each entry is expected to be an array with keys: **name**, **type**, **description**, **defaultValue**. See [Field Arguments](#field-arguments) section below.
-resolve | `callable` | **function($rootValue, $args, $context, [ResolveInfo](../reference.md#graphqltypedefinitionresolveinfo) $info)**
Given the **$value** of this type, it is expected to return actual value of the current field. See section on [Data Fetching](../data-fetching.md) for details
+resolve | `callable` | **function($objectValue, $args, $context, [ResolveInfo](../reference.md#graphqltypedefinitionresolveinfo) $info)**
Given the **$objectValue** of this type, it is expected to return actual value of the current field. See section on [Data Fetching](../data-fetching.md) for details
complexity | `callable` | **function($childrenComplexity, $args)**
Used to restrict query complexity. The feature is disabled by default, read about [Security](../security.md#query-complexity-analysis) to use it.
description | `string` | Plain-text description of this field for clients (e.g. used by [GraphiQL](https://github.com/graphql/graphiql) for auto-generated documentation)
deprecationReason | `string` | Text describing why this field is deprecated. When not empty - field will not be returned by introspection queries (unless forced)
diff --git a/examples/00-hello-world/graphql.php b/examples/00-hello-world/graphql.php
index 167b44d..7f933ad 100644
--- a/examples/00-hello-world/graphql.php
+++ b/examples/00-hello-world/graphql.php
@@ -35,7 +35,7 @@ try {
'x' => ['type' => Type::int()],
'y' => ['type' => Type::int()],
],
- 'resolve' => function ($rootValue, $args) {
+ 'resolve' => function ($calc, $args) {
return $args['x'] + $args['y'];
},
],
diff --git a/examples/01-blog/Blog/Type/CommentType.php b/examples/01-blog/Blog/Type/CommentType.php
index c61e338..8a97a3a 100644
--- a/examples/01-blog/Blog/Type/CommentType.php
+++ b/examples/01-blog/Blog/Type/CommentType.php
@@ -35,12 +35,12 @@ class CommentType extends ObjectType
Types::htmlField('body')
];
},
- 'resolveField' => function($rootValue, $args, $context, ResolveInfo $info) {
+ 'resolveField' => function($comment, $args, $context, ResolveInfo $info) {
$method = 'resolve' . ucfirst($info->fieldName);
if (method_exists($this, $method)) {
- return $this->{$method}($rootValue, $args, $context, $info);
+ return $this->{$method}($comment, $args, $context, $info);
} else {
- return $rootValue->{$info->fieldName};
+ return $comment->{$info->fieldName};
}
}
];
diff --git a/examples/01-blog/Blog/Type/StoryType.php b/examples/01-blog/Blog/Type/StoryType.php
index 1df1f37..1abb897 100644
--- a/examples/01-blog/Blog/Type/StoryType.php
+++ b/examples/01-blog/Blog/Type/StoryType.php
@@ -75,12 +75,12 @@ class StoryType extends ObjectType
'interfaces' => [
Types::node()
],
- 'resolveField' => function($rootValue, $args, $context, ResolveInfo $info) {
+ 'resolveField' => function($story, $args, $context, ResolveInfo $info) {
$method = 'resolve' . ucfirst($info->fieldName);
if (method_exists($this, $method)) {
- return $this->{$method}($rootValue, $args, $context, $info);
+ return $this->{$method}($story, $args, $context, $info);
} else {
- return $rootValue->{$info->fieldName};
+ return $story->{$info->fieldName};
}
}
];
diff --git a/examples/01-blog/Blog/Type/UserType.php b/examples/01-blog/Blog/Type/UserType.php
index cb5922d..b185f74 100644
--- a/examples/01-blog/Blog/Type/UserType.php
+++ b/examples/01-blog/Blog/Type/UserType.php
@@ -44,12 +44,12 @@ class UserType extends ObjectType
'interfaces' => [
Types::node()
],
- 'resolveField' => function($rootValue, $args, $context, ResolveInfo $info) {
+ 'resolveField' => function($user, $args, $context, ResolveInfo $info) {
$method = 'resolve' . ucfirst($info->fieldName);
if (method_exists($this, $method)) {
- return $this->{$method}($rootValue, $args, $context, $info);
+ return $this->{$method}($user, $args, $context, $info);
} else {
- return $rootValue->{$info->fieldName};
+ return $user->{$info->fieldName};
}
}
];
diff --git a/examples/03-server/graphql.php b/examples/03-server/graphql.php
index 8b73f44..c0240da 100644
--- a/examples/03-server/graphql.php
+++ b/examples/03-server/graphql.php
@@ -35,7 +35,7 @@ try {
'x' => ['type' => Type::int()],
'y' => ['type' => Type::int()],
],
- 'resolve' => function ($rootValue, $args) {
+ 'resolve' => function ($calc, $args) {
return $args['x'] + $args['y'];
},
],
diff --git a/tests/Executor/DeferredFieldsTest.php b/tests/Executor/DeferredFieldsTest.php
index 787e2c9..957b5a8 100644
--- a/tests/Executor/DeferredFieldsTest.php
+++ b/tests/Executor/DeferredFieldsTest.php
@@ -401,7 +401,7 @@ class DeferredFieldsTest extends TestCase
return [
'sync' => [
'type' => Type::string(),
- 'resolve' => function ($rootValue, $args, $context, ResolveInfo $info) {
+ 'resolve' => function ($complexType, $args, $context, ResolveInfo $info) {
$this->paths[] = $info->path;
return 'sync';
@@ -409,7 +409,7 @@ class DeferredFieldsTest extends TestCase
],
'deferred' => [
'type' => Type::string(),
- 'resolve' => function ($rootValue, $args, $context, ResolveInfo $info) {
+ 'resolve' => function ($complexType, $args, $context, ResolveInfo $info) {
$this->paths[] = $info->path;
return new Deferred(function () use ($info) {
@@ -421,7 +421,7 @@ class DeferredFieldsTest extends TestCase
],
'nest' => [
'type' => $complexType,
- 'resolve' => function ($rootValue, $args, $context, ResolveInfo $info) {
+ 'resolve' => function ($complexType, $args, $context, ResolveInfo $info) {
$this->paths[] = $info->path;
return [];
@@ -429,7 +429,7 @@ class DeferredFieldsTest extends TestCase
],
'deferredNest' => [
'type' => $complexType,
- 'resolve' => function ($rootValue, $args, $context, ResolveInfo $info) {
+ 'resolve' => function ($complexType, $args, $context, ResolveInfo $info) {
$this->paths[] = $info->path;
return new Deferred(function () use ($info) {
diff --git a/tests/Executor/ExecutorTest.php b/tests/Executor/ExecutorTest.php
index 76b4beb..eb8e4a1 100644
--- a/tests/Executor/ExecutorTest.php
+++ b/tests/Executor/ExecutorTest.php
@@ -273,7 +273,7 @@ class ExecutorTest extends TestCase
'fields' => [
'test' => [
'type' => Type::string(),
- 'resolve' => static function ($rootValue, $args, $ctx, $_info) use (&$info) {
+ 'resolve' => static function ($test, $args, $ctx, $_info) use (&$info) {
$info = $_info;
},
],
diff --git a/tests/Executor/TestClasses/Adder.php b/tests/Executor/TestClasses/Adder.php
index 416cd5e..562aba6 100644
--- a/tests/Executor/TestClasses/Adder.php
+++ b/tests/Executor/TestClasses/Adder.php
@@ -16,7 +16,7 @@ class Adder
{
$this->num = $num;
- $this->test = function ($rootValue, $args, $context) {
+ $this->test = function ($objectValue, $args, $context) {
return $this->num + $args['addend1'] + $context['addend2'];
};
}
diff --git a/tests/Regression/Issue396Test.php b/tests/Regression/Issue396Test.php
index f7c26a9..ca5e5c0 100644
--- a/tests/Regression/Issue396Test.php
+++ b/tests/Regression/Issue396Test.php
@@ -30,7 +30,7 @@ class Issue396Test extends TestCase
$unionResult = new UnionType([
'name' => 'UnionResult',
'types' => [$a, $b, $c],
- 'resolveType' => static function ($result, $rootValue, ResolveInfo $info) use ($a, $b, $c, &$log) : Type {
+ 'resolveType' => static function ($result, $value, ResolveInfo $info) use ($a, $b, $c, &$log) : Type {
$log[] = [$result, $info->path];
if (stristr($result['name'], 'A')) {
return $a;
@@ -97,7 +97,7 @@ class Issue396Test extends TestCase
'fields' => [
'name' => Type::string(),
],
- 'resolveType' => static function ($result, $rootValue, ResolveInfo $info) use (&$a, &$b, &$c, &$log) : Type {
+ 'resolveType' => static function ($result, $value, ResolveInfo $info) use (&$a, &$b, &$c, &$log) : Type {
$log[] = [$result, $info->path];
if (stristr($result['name'], 'A')) {
return $a;
diff --git a/tests/Type/IntrospectionTest.php b/tests/Type/IntrospectionTest.php
index afea3d9..d38bda1 100644
--- a/tests/Type/IntrospectionTest.php
+++ b/tests/Type/IntrospectionTest.php
@@ -1049,7 +1049,7 @@ class IntrospectionTest extends TestCase
'field' => [
'type' => Type::string(),
'args' => ['complex' => ['type' => $TestInputObject]],
- 'resolve' => static function ($rootValue, $args) {
+ 'resolve' => static function ($testType, $args) {
return json_encode($args['complex']);
},
],