Reverted one minor breaking change

This commit is contained in:
vladar 2016-10-22 17:18:16 +07:00
parent a612b780c9
commit 276a58f6d1
3 changed files with 2 additions and 42 deletions

View File

@ -39,46 +39,6 @@ GraphQL\Schema::$queryType;
So if you rely on any protected properties or methods of any GraphQL class, make sure to
delete leading underscores.
### 3. Returning closure from field resolver
Previously when you returned closure from any resolver, expected signature of this closure
was `function($sourceValue)`, new signature is `function($args, $context)`
(now mirrors reference graphql-js implementation)
Before the change:
```php
new ObjectType([
'name' => 'Test',
'fields' => [
'a' => [
'type' => Type::string(),
'resolve' => function() {
return function($value) {
return 'something';
}
}
]
]
])
```
After the change:
```php
new ObjectType([
'name' => 'Test',
'fields' => [
'a' => [
'type' => Type::string(),
'resolve' => function() {
return function($args, $context) {
return 'something';
}
}
]
]
])
```
(note the closure signature change)
## Upgrade v0.6.x > v0.7.x
There are a few new breaking changes in v0.7.0 that were added to the graphql-js reference implementation

View File

@ -675,7 +675,7 @@ class Executor
}
}
return $property instanceof \Closure ? $property($args, $context) : $property;
return $property instanceof \Closure ? $property($source, $args, $context) : $property;
}
/**

View File

@ -107,7 +107,7 @@ class Adder
{
$this->num = $num;
$this->test = function($args, $context) {
$this->test = function($source, $args, $context) {
return $this->num + $args['addend1'] + $context['addend2'];
};
}