mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-23 13:26:04 +03:00
Fix up some overly eager renamings in the docs
This commit is contained in:
parent
3b33167c87
commit
8c4e7b178d
@ -103,25 +103,25 @@ for a field you simply override this default resolver.
|
|||||||
**graphql-php** provides following default field resolver:
|
**graphql-php** provides following default field resolver:
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
function defaultFieldResolver($rootValue, $args, $context, \GraphQL\Type\Definition\ResolveInfo $info)
|
function defaultFieldResolver($objectValue, $args, $context, \GraphQL\Type\Definition\ResolveInfo $info)
|
||||||
{
|
{
|
||||||
$fieldName = $info->fieldName;
|
$fieldName = $info->fieldName;
|
||||||
$property = null;
|
$property = null;
|
||||||
|
|
||||||
if (is_array($rootValue) || $rootValue instanceof ArrayAccess) {
|
if (is_array($objectValue) || $objectValue instanceof \ArrayAccess) {
|
||||||
if (isset($rootValue[$fieldName])) {
|
if (isset($objectValue[$fieldName])) {
|
||||||
$property = $rootValue[$fieldName];
|
$property = $objectValue[$fieldName];
|
||||||
}
|
}
|
||||||
} elseif (is_object($rootValue)) {
|
} elseif (is_object($objectValue)) {
|
||||||
if (isset($rootValue->{$fieldName})) {
|
if (isset($objectValue->{$fieldName})) {
|
||||||
$property = $rootValue->{$fieldName};
|
$property = $objectValue->{$fieldName};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $property instanceof Closure
|
||||||
|
? $property($objectValue, $args, $context, $info)
|
||||||
|
: $property;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $property instanceof Closure
|
|
||||||
? $property($rootValue, $args, $context, $info)
|
|
||||||
: $property;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
As you see it returns value by key (for arrays) or property (for objects).
|
As you see it returns value by key (for arrays) or property (for objects).
|
||||||
@ -163,7 +163,6 @@ $userType = new ObjectType([
|
|||||||
Keep in mind that **field resolver** has precedence over **default field resolver per type** which in turn
|
Keep in mind that **field resolver** has precedence over **default field resolver per type** which in turn
|
||||||
has precedence over **default field resolver**.
|
has precedence over **default field resolver**.
|
||||||
|
|
||||||
|
|
||||||
# Solving N+1 Problem
|
# Solving N+1 Problem
|
||||||
Since: 0.9.0
|
Since: 0.9.0
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ See [related documentation](executing-queries.md).
|
|||||||
* fieldResolver:
|
* fieldResolver:
|
||||||
* A resolver function to use when one is not provided by the schema.
|
* A resolver function to use when one is not provided by the schema.
|
||||||
* If not provided, the default field resolver is used (which looks for a
|
* If not provided, the default field resolver is used (which looks for a
|
||||||
* value on the root value with the field's name).
|
* value on the object value with the field's name).
|
||||||
* validationRules:
|
* validationRules:
|
||||||
* A set of rules for query validation step. Default value is all available rules.
|
* A set of rules for query validation step. Default value is all available rules.
|
||||||
* Empty array would allow to skip query validation (may be convenient for persisted
|
* Empty array would allow to skip query validation (may be convenient for persisted
|
||||||
@ -998,7 +998,7 @@ visitor API:
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
static function visit($rootValue, $visitor, $keyMap = null)
|
static function visit($root, $visitor, $keyMap = null)
|
||||||
```
|
```
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
@ -161,29 +161,29 @@ class Executor
|
|||||||
* and returns it as the result, or if it's a function, returns the result
|
* and returns it as the result, or if it's a function, returns the result
|
||||||
* of calling that function while passing along args and context.
|
* of calling that function while passing along args and context.
|
||||||
*
|
*
|
||||||
* @param mixed $rootValue
|
* @param mixed $objectValue
|
||||||
* @param mixed[] $args
|
* @param mixed[] $args
|
||||||
* @param mixed|null $context
|
* @param mixed|null $context
|
||||||
*
|
*
|
||||||
* @return mixed|null
|
* @return mixed|null
|
||||||
*/
|
*/
|
||||||
public static function defaultFieldResolver($rootValue, $args, $context, ResolveInfo $info)
|
public static function defaultFieldResolver($objectValue, $args, $context, ResolveInfo $info)
|
||||||
{
|
{
|
||||||
$fieldName = $info->fieldName;
|
$fieldName = $info->fieldName;
|
||||||
$property = null;
|
$property = null;
|
||||||
|
|
||||||
if (is_array($rootValue) || $rootValue instanceof ArrayAccess) {
|
if (is_array($objectValue) || $objectValue instanceof ArrayAccess) {
|
||||||
if (isset($rootValue[$fieldName])) {
|
if (isset($objectValue[$fieldName])) {
|
||||||
$property = $rootValue[$fieldName];
|
$property = $objectValue[$fieldName];
|
||||||
}
|
}
|
||||||
} elseif (is_object($rootValue)) {
|
} elseif (is_object($objectValue)) {
|
||||||
if (isset($rootValue->{$fieldName})) {
|
if (isset($objectValue->{$fieldName})) {
|
||||||
$property = $rootValue->{$fieldName};
|
$property = $objectValue->{$fieldName};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $property instanceof Closure
|
return $property instanceof Closure
|
||||||
? $property($rootValue, $args, $context, $info)
|
? $property($objectValue, $args, $context, $info)
|
||||||
: $property;
|
: $property;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user