From 19a37609f4ba53d6e7ce13ee0644b65b821fb154 Mon Sep 17 00:00:00 2001 From: spawnia Date: Sun, 30 Jun 2019 23:08:24 +0200 Subject: [PATCH] Add a few more --- benchmarks/Utils/SchemaGenerator.php | 2 +- docs/type-system/object-types.md | 4 ++-- examples/01-blog/Blog/Type/CommentType.php | 6 +++--- examples/01-blog/Blog/Type/StoryType.php | 6 +++--- examples/01-blog/Blog/Type/UserType.php | 6 +++--- src/Type/Definition/ObjectType.php | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/benchmarks/Utils/SchemaGenerator.php b/benchmarks/Utils/SchemaGenerator.php index 8ee39e7..495ad8f 100644 --- a/benchmarks/Utils/SchemaGenerator.php +++ b/benchmarks/Utils/SchemaGenerator.php @@ -152,7 +152,7 @@ class SchemaGenerator ]; } - public function resolveField($value, $args, $context, $resolveInfo) + public function resolveField($rootValue, $args, $context, $resolveInfo) { return $resolveInfo->fieldName . '-value'; } diff --git a/docs/type-system/object-types.md b/docs/type-system/object-types.md index 9c1f2fb..c12595a 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($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). +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). 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($value, $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($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 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/01-blog/Blog/Type/CommentType.php b/examples/01-blog/Blog/Type/CommentType.php index cbcad4d..c61e338 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($value, $args, $context, ResolveInfo $info) { + 'resolveField' => function($rootValue, $args, $context, ResolveInfo $info) { $method = 'resolve' . ucfirst($info->fieldName); if (method_exists($this, $method)) { - return $this->{$method}($value, $args, $context, $info); + return $this->{$method}($rootValue, $args, $context, $info); } else { - return $value->{$info->fieldName}; + return $rootValue->{$info->fieldName}; } } ]; diff --git a/examples/01-blog/Blog/Type/StoryType.php b/examples/01-blog/Blog/Type/StoryType.php index 32cea4e..1df1f37 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($value, $args, $context, ResolveInfo $info) { + 'resolveField' => function($rootValue, $args, $context, ResolveInfo $info) { $method = 'resolve' . ucfirst($info->fieldName); if (method_exists($this, $method)) { - return $this->{$method}($value, $args, $context, $info); + return $this->{$method}($rootValue, $args, $context, $info); } else { - return $value->{$info->fieldName}; + return $rootValue->{$info->fieldName}; } } ]; diff --git a/examples/01-blog/Blog/Type/UserType.php b/examples/01-blog/Blog/Type/UserType.php index 9960b62..cb5922d 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($value, $args, $context, ResolveInfo $info) { + 'resolveField' => function($rootValue, $args, $context, ResolveInfo $info) { $method = 'resolve' . ucfirst($info->fieldName); if (method_exists($this, $method)) { - return $this->{$method}($value, $args, $context, $info); + return $this->{$method}($rootValue, $args, $context, $info); } else { - return $value->{$info->fieldName}; + return $rootValue->{$info->fieldName}; } } ]; diff --git a/src/Type/Definition/ObjectType.php b/src/Type/Definition/ObjectType.php index 532a9b0..d464b45 100644 --- a/src/Type/Definition/ObjectType.php +++ b/src/Type/Definition/ObjectType.php @@ -200,7 +200,7 @@ class ObjectType extends Type implements OutputType, CompositeType, NullableType } /** - * @param mixed[] $value + * @param mixed $value * @param mixed[]|null $context * * @return bool|null