Skip to content

Commit 45b7769

Browse files
committed
fix incorrect caching on mutation types of FieldtypeOptionsInput
1 parent ffb90bc commit 45b7769

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Type/Fieldtype/FieldtypeOptions.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use GraphQL\Type\Definition\ObjectType;
66
use ProcessWire\GraphQL\Cache;
77
use ProcessWire\InputfieldSelectMultiple;
8+
use ProcessWire\Field;
9+
use ProcessWire\GraphQL\Utils;
810
use ProcessWire\GraphQL\Type\Fieldtype\Traits\SetValueTrait;
911
use ProcessWire\GraphQL\Type\Fieldtype\Traits\FieldTrait;
1012

@@ -63,7 +65,7 @@ public static function type($field)
6365

6466
public static function inputType($field)
6567
{
66-
return Cache::type(self::$inputName, function () use ($field) {
68+
return Cache::type(self::getName($field), function () use ($field) {
6769
$options = [];
6870
foreach ($field->type->getOptions($field) as $option) {
6971
$options[$option->title ? $option->title : $option->value] = [
@@ -73,7 +75,7 @@ public static function inputType($field)
7375
}
7476

7577
$type = new EnumType([
76-
'name' => self::$inputName,
78+
'name' => self::getName($field),
7779
'description' => "Possible values for the ". self::$name .".",
7880
'values' => $options,
7981
]);
@@ -110,4 +112,13 @@ public static function inputField($field)
110112
];
111113
});
112114
}
115+
116+
public static function getName(Field $field = null)
117+
{
118+
if ($field instanceof Field) {
119+
return Utils::normalizeTypeName("{$field->name}".self::$inputName);
120+
}
121+
122+
return self::$inputName;
123+
}
113124
}

0 commit comments

Comments
 (0)