Skip to content

Commit

Permalink
Fix GraphQL mutations. Blocks now require type_blockTypeId. (see #449)
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Jan 24, 2022
1 parent aeb50ce commit 32f8e2d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/gql/types/input/SuperTableBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ public static function getType(SuperTableField $context)
$blockTypeFields[$field->handle] = $field->getContentGqlMutationArgumentType();
}

$blockTypeGqlName = $context->handle . '_' . $blockType->handle . '_SuperTableBlockInput';
$blockInputTypes[$blockType->handle] = [
'name' => $blockType->handle,
$blockTypeGqlName = $context->handle . '_' . $blockType->id . '_SuperTableBlockInput';

$blockInputTypes['type_' . $blockType->id] = [
'name' => 'type_' . $blockType->id,
'type' => GqlEntityRegistry::createEntity($blockTypeGqlName, new InputObjectType([
'name' => $blockTypeGqlName,
'fields' => $blockTypeFields
Expand Down Expand Up @@ -97,7 +98,7 @@ public static function normalizeValue($value)
if (!empty($value['blocks'])) {
foreach ($value['blocks'] as $block) {
if (!empty($block)) {
$type = array_key_first($block);
$type = str_replace('type_', '', array_key_first($block));
$block = reset($block);
$missingId = $missingId || empty($block['id']);
$blockId = !empty($block['id']) ? $block['id'] : 'new:' . ($blockCounter++);
Expand Down

0 comments on commit 32f8e2d

Please sign in to comment.