mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-21 20:36:05 +03:00
Add a few more
This commit is contained in:
parent
24f236403a
commit
19a37609f4
@ -152,7 +152,7 @@ class SchemaGenerator
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resolveField($value, $args, $context, $resolveInfo)
|
public function resolveField($rootValue, $args, $context, $resolveInfo)
|
||||||
{
|
{
|
||||||
return $resolveInfo->fieldName . '-value';
|
return $resolveInfo->fieldName . '-value';
|
||||||
}
|
}
|
||||||
|
@ -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.
|
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)
|
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.
|
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)**<br> 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)**<br> 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)**<br> 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.
|
resolveField | `callable` | **function($value, $args, $context, [ResolveInfo](../reference.md#graphqltypedefinitionresolveinfo) $info)**<br> 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
|
# 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)
|
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))
|
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.
|
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)**<br> 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)**<br> 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)**<br> Used to restrict query complexity. The feature is disabled by default, read about [Security](../security.md#query-complexity-analysis) to use it.
|
complexity | `callable` | **function($childrenComplexity, $args)**<br> 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)
|
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)
|
deprecationReason | `string` | Text describing why this field is deprecated. When not empty - field will not be returned by introspection queries (unless forced)
|
||||||
|
@ -35,12 +35,12 @@ class CommentType extends ObjectType
|
|||||||
Types::htmlField('body')
|
Types::htmlField('body')
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
'resolveField' => function($value, $args, $context, ResolveInfo $info) {
|
'resolveField' => function($rootValue, $args, $context, ResolveInfo $info) {
|
||||||
$method = 'resolve' . ucfirst($info->fieldName);
|
$method = 'resolve' . ucfirst($info->fieldName);
|
||||||
if (method_exists($this, $method)) {
|
if (method_exists($this, $method)) {
|
||||||
return $this->{$method}($value, $args, $context, $info);
|
return $this->{$method}($rootValue, $args, $context, $info);
|
||||||
} else {
|
} else {
|
||||||
return $value->{$info->fieldName};
|
return $rootValue->{$info->fieldName};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -75,12 +75,12 @@ class StoryType extends ObjectType
|
|||||||
'interfaces' => [
|
'interfaces' => [
|
||||||
Types::node()
|
Types::node()
|
||||||
],
|
],
|
||||||
'resolveField' => function($value, $args, $context, ResolveInfo $info) {
|
'resolveField' => function($rootValue, $args, $context, ResolveInfo $info) {
|
||||||
$method = 'resolve' . ucfirst($info->fieldName);
|
$method = 'resolve' . ucfirst($info->fieldName);
|
||||||
if (method_exists($this, $method)) {
|
if (method_exists($this, $method)) {
|
||||||
return $this->{$method}($value, $args, $context, $info);
|
return $this->{$method}($rootValue, $args, $context, $info);
|
||||||
} else {
|
} else {
|
||||||
return $value->{$info->fieldName};
|
return $rootValue->{$info->fieldName};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -44,12 +44,12 @@ class UserType extends ObjectType
|
|||||||
'interfaces' => [
|
'interfaces' => [
|
||||||
Types::node()
|
Types::node()
|
||||||
],
|
],
|
||||||
'resolveField' => function($value, $args, $context, ResolveInfo $info) {
|
'resolveField' => function($rootValue, $args, $context, ResolveInfo $info) {
|
||||||
$method = 'resolve' . ucfirst($info->fieldName);
|
$method = 'resolve' . ucfirst($info->fieldName);
|
||||||
if (method_exists($this, $method)) {
|
if (method_exists($this, $method)) {
|
||||||
return $this->{$method}($value, $args, $context, $info);
|
return $this->{$method}($rootValue, $args, $context, $info);
|
||||||
} else {
|
} else {
|
||||||
return $value->{$info->fieldName};
|
return $rootValue->{$info->fieldName};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -200,7 +200,7 @@ class ObjectType extends Type implements OutputType, CompositeType, NullableType
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed[] $value
|
* @param mixed $value
|
||||||
* @param mixed[]|null $context
|
* @param mixed[]|null $context
|
||||||
*
|
*
|
||||||
* @return bool|null
|
* @return bool|null
|
||||||
|
Loading…
Reference in New Issue
Block a user