Skip to content

Commit

Permalink
Fix merge regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Mooyman committed Mar 20, 2018
1 parent 932e628 commit e277f19
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/Scaffolding/Scaffolders/CRUD/Update.php
Expand Up @@ -112,15 +112,17 @@ protected function inputTypeName()

public function resolve($object, $args, $context, $info)
{
$input = $args['Input'];
$obj = DataList::create($this->dataObjectClass)
->byID($args['ID']);
->byID($input['ID']);
if (!$obj) {
throw new Exception(sprintf(
'%s with ID %s not found',
$this->dataObjectClass,
$args['ID']
$input['ID']
));
}
unset($input['ID']);
if (!$obj->canEdit($context['currentUser'])) {
throw new Exception(sprintf(
'Cannot edit this %s',
Expand All @@ -134,7 +136,7 @@ public function resolve($object, $args, $context, $info)
return $obj;
}

$obj->update($args['Input']);
$obj->update($input);
$obj->write();
return $obj;
}
Expand Down
10 changes: 2 additions & 8 deletions tests/Scaffolding/Scaffolders/CRUD/UpdateTest.php
Expand Up @@ -65,7 +65,7 @@ public function testUpdateOperationResolver($shouldExtend)
$record,
[
'Input' => [
'ID' => $ID,
'ID' => $ID,
'MyField' => 'new'
],
],
Expand Down Expand Up @@ -95,7 +95,7 @@ public function testUpdateOperationInputType()

// Test args
$args = $scaffold['args'];
$this->assertEquals(['ID', 'Input', 'MyField'], array_keys($args));
$this->assertEquals(['Input', 'MyField'], array_keys($args));

/** @var NonNull $inputType */
$inputType = $args['Input']['type'];
Expand All @@ -105,13 +105,7 @@ public function testUpdateOperationInputType()
$this->assertInstanceOf(InputObjectType::class, $inputTypeWrapped);
$this->assertEquals('GraphQL_DataObjectFakeUpdateInputType', $inputTypeWrapped->toString());

/** @var NonNull $idType */
$idType = $args['ID']['type'];
$this->assertInstanceOf(NonNull::class, $idType);
$this->assertInstanceOf(IDType::class, $idType->getWrappedType());

// Custom field
$this->assertArrayHasKey('MyField', $args);
$this->assertInstanceOf(StringType::class, $args['MyField']['type']);

// Test fields
Expand Down

0 comments on commit e277f19

Please sign in to comment.