|
31 | 31 | use DataValues\StringValue; |
32 | 32 | use DataValues\TimeValue; |
33 | 33 | use DataValues\UnboundedQuantityValue; |
| 34 | +use GraphQL\Type\Definition\ObjectType; |
| 35 | +use GraphQL\Type\Definition\Type; |
34 | 36 | use MediaWiki\Logger\LoggerFactory; |
35 | 37 | use MediaWiki\MediaWikiServices; |
36 | 38 | use ValueFormatters\FormatterOptions; |
|
45 | 47 | use Wikibase\Lib\Formatters\SnakFormatter; |
46 | 48 | use Wikibase\Lib\Store\FieldPropertyInfoProvider; |
47 | 49 | use Wikibase\Lib\Store\PropertyInfoStore; |
| 50 | +use Wikibase\Repo\Domains\Reuse\Domain\Model\Value; |
48 | 51 | use Wikibase\Repo\Parsers\EntityIdValueParser; |
49 | 52 | use Wikibase\Repo\Parsers\MediaWikiNumberUnlocalizer; |
50 | 53 | use Wikibase\Repo\Parsers\MonolingualTextParser; |
|
300 | 303 | 'normalizer-factory-callback' => static function () { |
301 | 304 | return WikibaseRepo::getStringValueNormalizer(); |
302 | 305 | }, |
| 306 | + 'graphql-value-type' => static function () { |
| 307 | + return new ObjectType( [ |
| 308 | + 'name' => 'StringValue', |
| 309 | + 'fields' => [ |
| 310 | + 'type' => [ |
| 311 | + 'type' => Type::nonNull( Type::string() ), |
| 312 | + 'resolve' => fn() => 'value', |
| 313 | + ], |
| 314 | + 'content' => [ |
| 315 | + 'type' => Type::nonNull( Type::string() ), |
| 316 | + 'resolve' => fn( Value $v ) => $v->content->getValue(), |
| 317 | + ], |
| 318 | + ], |
| 319 | + ] ); |
| 320 | + }, |
303 | 321 | ], |
304 | 322 | 'VT:time' => [ |
305 | 323 | 'expert-module' => 'jquery.valueview.experts.TimeInput', |
|
453 | 471 | 'rdf-data-type' => function() { |
454 | 472 | return PropertySpecificComponentsRdfBuilder::OBJECT_PROPERTY; |
455 | 473 | }, |
| 474 | + 'graphql-value-type' => static function() { |
| 475 | + return new ObjectType( [ |
| 476 | + 'name' => 'ItemValue', |
| 477 | + 'fields' => [ |
| 478 | + 'type' => [ |
| 479 | + 'type' => Type::nonNull( Type::string() ), |
| 480 | + 'resolve' => fn() => 'value', |
| 481 | + ], |
| 482 | + 'content' => [ |
| 483 | + 'type' => Type::nonNull( new ObjectType( [ |
| 484 | + 'name' => 'ValueItem', |
| 485 | + 'fields' => [ |
| 486 | + 'id' => [ |
| 487 | + 'type' => Type::nonNull( Type::string() ), |
| 488 | + 'resolve' => fn( EntityIdValue $content ) => $content->getEntityId()->getSerialization(), |
| 489 | + ], |
| 490 | + ], |
| 491 | + ] ) ), |
| 492 | + 'resolve' => fn( Value $v ) => $v->content, |
| 493 | + ], |
| 494 | + ], |
| 495 | + ] ); |
| 496 | + }, |
456 | 497 | ], |
457 | 498 | 'PT:wikibase-property' => [ |
458 | 499 | 'expert-module' => 'wikibase.experts.Property', |
|
0 commit comments