init
This commit is contained in:
+241
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Framework\GraphQl\Config;
|
||||
|
||||
use Magento\Framework\App\Cache;
|
||||
use Magento\Framework\App\Request\Http;
|
||||
use Magento\Framework\GraphQl\Config;
|
||||
use Magento\Framework\GraphQl\Schema\SchemaGenerator;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\Serialize\SerializerInterface;
|
||||
use Magento\GraphQl\Controller\GraphQl;
|
||||
|
||||
/**
|
||||
* Tests the entire process of generating a schema from a given SDL and processing a request/query
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
* @magentoAppArea graphql
|
||||
*/
|
||||
class GraphQlReaderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var Config */
|
||||
private $configModel;
|
||||
|
||||
/** @var GraphQl */
|
||||
private $graphQlController;
|
||||
|
||||
/** @var ObjectManagerInterface */
|
||||
private $objectManager;
|
||||
|
||||
/** @var SerializerInterface */
|
||||
private $jsonSerializer;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
/** @var Cache $cache */
|
||||
$cache = $this->objectManager->get(Cache::class);
|
||||
$cache->clean();
|
||||
$fileResolverMock = $this->getMockBuilder(
|
||||
\Magento\Framework\Config\FileResolverInterface::class
|
||||
)->disableOriginalConstructor()->getMock();
|
||||
$filePath1 = __DIR__ . '/../_files/schemaA.graphqls';
|
||||
$filePath2 = __DIR__ . '/../_files/schemaB.graphqls';
|
||||
$fileList = [
|
||||
$filePath1 => file_get_contents($filePath1),
|
||||
$filePath2 => file_get_contents($filePath2)
|
||||
];
|
||||
$fileResolverMock->expects($this->any())->method('get')->willReturn($fileList);
|
||||
$graphQlReader = $this->objectManager->create(
|
||||
\Magento\Framework\GraphQlSchemaStitching\GraphQlReader::class,
|
||||
['fileResolver' => $fileResolverMock]
|
||||
);
|
||||
$reader = $this->objectManager->create(
|
||||
// phpstan:ignore
|
||||
\Magento\Framework\GraphQlSchemaStitching\Reader::class,
|
||||
['readers' => ['graphql_reader' => $graphQlReader]]
|
||||
);
|
||||
$data = $this->objectManager->create(
|
||||
// phpstan:ignore
|
||||
\Magento\Framework\GraphQl\Config\Data ::class,
|
||||
['reader' => $reader]
|
||||
);
|
||||
$this->configModel = $this->objectManager->create(
|
||||
\Magento\Framework\GraphQl\Config::class,
|
||||
['data' => $data]
|
||||
);
|
||||
$outputMapper = $this->objectManager->create(
|
||||
\Magento\Framework\GraphQl\Schema\Type\Output\OutputMapper::class,
|
||||
['config' => $this->configModel]
|
||||
);
|
||||
$schemaGenerator = $this->objectManager->create(
|
||||
SchemaGenerator::class,
|
||||
['outputMapper' => $outputMapper]
|
||||
);
|
||||
$this->graphQlController = $this->objectManager->create(
|
||||
GraphQl::class,
|
||||
['schemaGenerator' => $schemaGenerator]
|
||||
);
|
||||
$this->jsonSerializer = $this->objectManager->get(SerializerInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
public function testDispatchIntrospectionWithCustomSDL()
|
||||
{
|
||||
$query
|
||||
= <<<QUERY
|
||||
query IntrospectionQuery {
|
||||
__schema {
|
||||
queryType { name }
|
||||
types {
|
||||
...FullType
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment FullType on __Type {
|
||||
kind
|
||||
name
|
||||
description
|
||||
fields(includeDeprecated: true) {
|
||||
name
|
||||
description
|
||||
args {
|
||||
...InputValue
|
||||
}
|
||||
type {
|
||||
...TypeRef
|
||||
}
|
||||
isDeprecated
|
||||
deprecationReason
|
||||
}
|
||||
inputFields {
|
||||
...InputValue
|
||||
}
|
||||
interfaces {
|
||||
...TypeRef
|
||||
}
|
||||
enumValues(includeDeprecated: true) {
|
||||
name
|
||||
description
|
||||
isDeprecated
|
||||
}
|
||||
possibleTypes {
|
||||
...TypeRef
|
||||
}
|
||||
}
|
||||
|
||||
fragment InputValue on __InputValue {
|
||||
name
|
||||
description
|
||||
type { ...TypeRef }
|
||||
defaultValue
|
||||
}
|
||||
|
||||
fragment TypeRef on __Type {
|
||||
kind
|
||||
name
|
||||
ofType {
|
||||
kind
|
||||
name
|
||||
ofType {
|
||||
kind
|
||||
name
|
||||
ofType {
|
||||
kind
|
||||
name
|
||||
ofType {
|
||||
kind
|
||||
name
|
||||
ofType {
|
||||
kind
|
||||
name
|
||||
ofType {
|
||||
kind
|
||||
name
|
||||
ofType {
|
||||
kind
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QUERY;
|
||||
$postData = [
|
||||
'query' => $query,
|
||||
'variables' => null,
|
||||
'operationName' => 'IntrospectionQuery'
|
||||
];
|
||||
/** @var Http $request */
|
||||
$request = $this->objectManager->get(Http::class);
|
||||
$request->setPathInfo('/graphql');
|
||||
$request->setMethod('POST');
|
||||
$request->setContent(json_encode($postData));
|
||||
$headers = $this->objectManager->create(\Laminas\Http\Headers::class)
|
||||
->addHeaders(['Content-Type' => 'application/json']);
|
||||
$request->setHeaders($headers);
|
||||
|
||||
$response = $this->graphQlController->dispatch($request);
|
||||
$output = $this->jsonSerializer->unserialize($response->getContent());
|
||||
$expectedOutput = require __DIR__ . '/../_files/schema_response_sdl_description.php';
|
||||
$schemaResponseFields = $output['data']['__schema']['types'];
|
||||
|
||||
foreach ($expectedOutput as $searchTerm) {
|
||||
$sortFields = ['inputFields', 'fields'];
|
||||
foreach ($sortFields as $sortField) {
|
||||
isset($searchTerm[$sortField]) && is_array($searchTerm[$sortField])
|
||||
? usort(
|
||||
$searchTerm[$sortField],
|
||||
function ($a, $b) {
|
||||
$cmpField = 'name';
|
||||
return isset($a[$cmpField]) && isset($b[$cmpField])
|
||||
? strcmp($a[$cmpField], $b[$cmpField]) : 0;
|
||||
}
|
||||
) : null;
|
||||
}
|
||||
|
||||
$this->assertTrue(
|
||||
(in_array($searchTerm, $schemaResponseFields)),
|
||||
'Missing type in the response'
|
||||
);
|
||||
}
|
||||
//Checks to make sure that the given description exists in the expectedOutput array
|
||||
$this->assertArrayHasKey(
|
||||
array_search(
|
||||
'Comment for empty PhysicalProductInterface',
|
||||
array_column($expectedOutput, 'description')
|
||||
),
|
||||
$expectedOutput
|
||||
);
|
||||
$this->assertArrayHasKey(
|
||||
array_search(
|
||||
'Comment for empty Enum',
|
||||
array_column($expectedOutput, 'description')
|
||||
),
|
||||
$expectedOutput
|
||||
);
|
||||
$this->assertArrayHasKey(
|
||||
array_search(
|
||||
'Comment for SearchResultPageInfo',
|
||||
array_column($expectedOutput, 'description')
|
||||
),
|
||||
$expectedOutput
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Framework\GraphQl;
|
||||
|
||||
use Magento\Framework\App\Cache;
|
||||
use Magento\Framework\GraphQl\Config\Config;
|
||||
use Magento\Framework\GraphQl\Config\Data\Argument;
|
||||
use Magento\Framework\GraphQl\Config\Data\Enum;
|
||||
use Magento\Framework\GraphQl\Config\Data\Field;
|
||||
use Magento\Framework\GraphQl\Config\Data\StructureInterface;
|
||||
use Magento\Framework\GraphQl\Config\Data\Type;
|
||||
use Magento\Framework\GraphQl\Config\Element\EnumValue;
|
||||
use Magento\Framework\GraphQl\Config\Element\InterfaceType;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
|
||||
/**
|
||||
* Test of schema configuration reading and parsing
|
||||
*/
|
||||
class GraphQlConfigTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var \Magento\Framework\GraphQl\Config */
|
||||
private $model;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
/** @var ObjectManagerInterface $objectManager */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
/** @var Cache $cache */
|
||||
$cache = $objectManager->get(Cache::class);
|
||||
$cache->clean();
|
||||
$fileResolverMock = $this->getMockBuilder(
|
||||
\Magento\Framework\Config\FileResolverInterface::class
|
||||
)->disableOriginalConstructor()->getMock();
|
||||
$filePath1 = __DIR__ . '/_files/schemaC.graphqls';
|
||||
$filePath2 = __DIR__ . '/_files/schemaD.graphqls';
|
||||
$fileList = [
|
||||
$filePath1 => file_get_contents($filePath1),
|
||||
$filePath2 => file_get_contents($filePath2)
|
||||
];
|
||||
$fileResolverMock->expects($this->any())->method('get')->willReturn($fileList);
|
||||
$graphQlReader = $objectManager->create(
|
||||
\Magento\Framework\GraphQlSchemaStitching\GraphQlReader::class,
|
||||
['fileResolver' => $fileResolverMock]
|
||||
);
|
||||
$reader = $objectManager->create(
|
||||
// phpstan:ignore
|
||||
\Magento\Framework\GraphQlSchemaStitching\Reader::class,
|
||||
['readers' => ['graphql_reader' => $graphQlReader]]
|
||||
);
|
||||
$data = $objectManager->create(
|
||||
// phpstan:ignore
|
||||
\Magento\Framework\GraphQl\Config\Data::class,
|
||||
['reader' => $reader]
|
||||
);
|
||||
$this->model = $objectManager->create(\Magento\Framework\GraphQl\Config::class, ['data' =>$data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* tests GraphQl type's structure object
|
||||
*/
|
||||
public function testGraphQlTypeAndFieldConfigStructure()
|
||||
{
|
||||
$query = 'Query';
|
||||
/** @var \Magento\Framework\GraphQl\Config\Element\Type $output */
|
||||
$output = $this->model->getConfigElement($query);
|
||||
$expectedOutputArray = require __DIR__ . '/_files/query_array_output.php';
|
||||
$this->assertEquals($output->getName(), $query);
|
||||
/** @var \Magento\Framework\GraphQl\Config\Element\Field $queryFields */
|
||||
$queryFields = $output->getFields();
|
||||
foreach (array_keys($queryFields) as $fieldKey) {
|
||||
$fieldAssertionMap = [
|
||||
['response_field' => 'name', 'expected_value' => $queryFields[$fieldKey]->getName()],
|
||||
['response_field' => 'type', 'expected_value' => $queryFields[$fieldKey]->getTypeName()],
|
||||
['response_field' => 'required', 'expected_value' => $queryFields[$fieldKey]->isRequired()],
|
||||
['response_field' => 'isList', 'expected_value' => $queryFields[$fieldKey]->isList()],
|
||||
['response_field' => 'resolver', 'expected_value' => $queryFields[$fieldKey]->getResolver()],
|
||||
['response_field' => 'description', 'expected_value' => $queryFields[$fieldKey]->getDescription()],
|
||||
[
|
||||
'response_field' => 'cache',
|
||||
'expected_value' => $queryFields[$fieldKey]->getCache(),
|
||||
'optional' => true
|
||||
]
|
||||
];
|
||||
$this->assertResponseFields($expectedOutputArray['Query']['fields'][$fieldKey], $fieldAssertionMap);
|
||||
/** @var \Magento\Framework\GraphQl\Config\Element\Argument[] $queryFieldArguments */
|
||||
$queryFieldArguments = $queryFields[$fieldKey]->getArguments();
|
||||
foreach (array_keys($queryFieldArguments) as $argumentKey) {
|
||||
$argumentAssertionMap = [
|
||||
['response_field' => 'name', 'expected_value' => $queryFieldArguments[$argumentKey]->getName()],
|
||||
['response_field' => 'type', 'expected_value' => $queryFieldArguments[$argumentKey]->getTypeName()],
|
||||
['response_field' => 'description', 'expected_value' => $queryFieldArguments[$argumentKey]
|
||||
->getDescription()],
|
||||
['response_field' => 'required', 'expected_value' => $queryFieldArguments[$argumentKey]
|
||||
->isRequired()],
|
||||
['response_field' => 'isList', 'expected_value' => $queryFieldArguments[$argumentKey]->isList()],
|
||||
['response_field' => 'itemsRequired', 'expected_value' => $queryFieldArguments[$argumentKey]
|
||||
->areItemsRequired()]
|
||||
];
|
||||
$this->assertResponseFields(
|
||||
$expectedOutputArray['Query']['fields'][$fieldKey]['arguments'][$argumentKey],
|
||||
$argumentAssertionMap
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expectedOutputArray['Query']['fields'][$fieldKey]['arguments'][$argumentKey]['defaultValue'],
|
||||
$queryFieldArguments[$argumentKey]->getDefaultValue()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Structured data object for configured GraphQL enum type.
|
||||
*/
|
||||
public function testGraphQlEnumTypeConfigStructure()
|
||||
{
|
||||
$queryEnum = 'PriceAdjustmentDescriptionEnum';
|
||||
/** @var \Magento\Framework\GraphQl\Config\Element\Enum $outputEnum */
|
||||
$outputEnum = $this->model->getConfigElement($queryEnum);
|
||||
/** @var EnumValue[] $outputEnumValues */
|
||||
$outputEnumValues = $outputEnum->getValues();
|
||||
$expectedOutputArray = require __DIR__ . '/_files/query_array_output.php';
|
||||
$this->assertEquals($outputEnum->getName(), $queryEnum);
|
||||
$this->assertEquals($outputEnum->getDescription(), 'Description for enumType PriceAdjustmentDescriptionEnum');
|
||||
|
||||
foreach (array_keys($outputEnumValues) as $outputEnumValue) {
|
||||
$this->assertEquals(
|
||||
$expectedOutputArray['PriceAdjustmentDescriptionEnum']['values'][$outputEnumValue]['name'],
|
||||
$outputEnumValues[$outputEnumValue]->getName()
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expectedOutputArray['PriceAdjustmentDescriptionEnum']['values'][$outputEnumValue]['value'],
|
||||
$outputEnumValues[$outputEnumValue]->getValue()
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expectedOutputArray['PriceAdjustmentDescriptionEnum']['values'][$outputEnumValue]['description'],
|
||||
$outputEnumValues[$outputEnumValue]->getDescription()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Structured data object for configured GraphQL type that implements an interface.
|
||||
*/
|
||||
public function testGraphQlTypeThatImplementsInterface()
|
||||
{
|
||||
$typeThatImplements = 'ProductLinks';
|
||||
/** @var \Magento\Framework\GraphQl\Config\Element\Type $outputInterface */
|
||||
$outputInterface = $this->model->getConfigElement($typeThatImplements);
|
||||
$expectedOutputArray = require __DIR__ . '/_files/query_array_output.php';
|
||||
$this->assertEquals($outputInterface->getName(), $typeThatImplements);
|
||||
$outputInterfaceValues = $outputInterface->getInterfaces();
|
||||
/** @var \Magento\Framework\GraphQl\Config\Element\Field[] $outputInterfaceFields */
|
||||
$outputInterfaceFields =$outputInterface->getFields();
|
||||
foreach (array_keys($outputInterfaceValues) as $outputInterfaceValue) {
|
||||
$this->assertEquals(
|
||||
$expectedOutputArray['ProductLinks']['interfaces'][$outputInterfaceValue]['interface'],
|
||||
$outputInterfaceValues[$outputInterfaceValue]['interface']
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expectedOutputArray['ProductLinks']['interfaces'][$outputInterfaceValue]['copyFields'],
|
||||
$outputInterfaceValues[$outputInterfaceValue]['copyFields']
|
||||
);
|
||||
}
|
||||
foreach (array_keys($outputInterfaceFields) as $outputInterfaceField) {
|
||||
$this->assertEquals(
|
||||
$expectedOutputArray['ProductLinks']['fields'][$outputInterfaceField]['name'],
|
||||
$outputInterfaceFields[$outputInterfaceField]->getName()
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expectedOutputArray['ProductLinks']['fields'][$outputInterfaceField]['type'],
|
||||
$outputInterfaceFields[$outputInterfaceField]->getTypeName()
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expectedOutputArray['ProductLinks']['fields'][$outputInterfaceField]['required'],
|
||||
$outputInterfaceFields[$outputInterfaceField]->isRequired()
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expectedOutputArray['ProductLinks']['fields'][$outputInterfaceField]['description'],
|
||||
$outputInterfaceFields[$outputInterfaceField]->getDescription()
|
||||
);
|
||||
$this->assertEmpty($outputInterfaceFields[$outputInterfaceField]->getArguments());
|
||||
}
|
||||
}
|
||||
|
||||
public function testGraphQlInterfaceConfigElement()
|
||||
{
|
||||
$interfaceType ='ProductLinksInterface';
|
||||
/** @var InterfaceType $outputConfigElement */
|
||||
$outputConfigElement = $this->model->getConfigElement($interfaceType);
|
||||
$expectedOutput = require __DIR__ . '/_files/query_array_output.php';
|
||||
$this->assertEquals($outputConfigElement->getName(), $expectedOutput['ProductLinksInterface']['name']);
|
||||
$this->assertEquals(
|
||||
$outputConfigElement->getTypeResolver(),
|
||||
$expectedOutput['ProductLinksInterface']['typeResolver']
|
||||
);
|
||||
$this->assertEquals(
|
||||
$outputConfigElement->getDescription(),
|
||||
$expectedOutput['ProductLinksInterface']['description']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $actualResponse
|
||||
* @param array $assertionMap ['response_field_name' => 'response_field_value', ...]
|
||||
* OR [['response_field' => $field, 'expected_value' => $value], ...]
|
||||
*/
|
||||
private function assertResponseFields($actualResponse, $assertionMap)
|
||||
{
|
||||
foreach ($assertionMap as $key => $assertionData) {
|
||||
$expectedValue = isset($assertionData['expected_value'])
|
||||
? $assertionData['expected_value']
|
||||
: $assertionData;
|
||||
$responseField = isset($assertionData['response_field']) ? $assertionData['response_field'] : $key;
|
||||
$this->assertNotNull(
|
||||
$expectedValue,
|
||||
"Value of '{$responseField}' field must not be NULL"
|
||||
);
|
||||
$optionalField = isset($assertionData['optional']) ? $assertionData['optional'] : false;
|
||||
if (!$optionalField || isset($actualResponse[$responseField])) {
|
||||
$this->assertEquals(
|
||||
$expectedValue,
|
||||
$actualResponse[$responseField],
|
||||
"Value of '{$responseField}' field in response does not match expected value: "
|
||||
. var_export($expectedValue, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
/** @var ObjectManagerInterface $objectManager */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
/** @var Cache $cache */
|
||||
$cache = $objectManager->get(Cache::class);
|
||||
$cache->clean();
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Framework\GraphQl\GraphQlSchemaStitching;
|
||||
|
||||
use Magento\Framework\GraphQlSchemaStitching\GraphQlReader;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Magento\Framework\Config\FileResolverInterface;
|
||||
use Magento\Framework\Config\FileIterator;
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
/**
|
||||
* Test of the stitching of graphql schemas together
|
||||
*/
|
||||
class GraphQlReaderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Object Manager Instance
|
||||
*
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var GraphQlReader|MockObject
|
||||
*/
|
||||
private $graphQlReader;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
/** @var ObjectManagerInterface $objectManager */
|
||||
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
|
||||
$this->graphQlReader = $this->objectManager->create(
|
||||
GraphQlReader::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test ensures that the global graphql schemas have all the required dependencies and can be stitched together
|
||||
*
|
||||
* The $results variables contains the actual schema as it will be on a production site which will vary per each
|
||||
* update of magento, so asserting the array matches the entire schema does not make full sense here as any change
|
||||
* in graphql in any magento module would break the test.
|
||||
*
|
||||
* Testing this way means we do not need to store the module meta data that was introduced in
|
||||
* https://github.com/magento/magento2/pull/28747 which means we can greatly improve the performance of this
|
||||
*/
|
||||
public function testStitchGlobalGraphQLSchema()
|
||||
{
|
||||
$results = $this->graphQlReader->read('global');
|
||||
|
||||
$this->assertArrayHasKey('Price', $results);
|
||||
$this->assertArrayHasKey('Query', $results);
|
||||
$this->assertArrayHasKey('Mutation', $results);
|
||||
$this->assertArrayHasKey('ProductInterface', $results);
|
||||
$this->assertArrayHasKey('SimpleProduct', $results);
|
||||
}
|
||||
}
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'Query' =>
|
||||
[
|
||||
'name' => 'Query',
|
||||
'fields' =>
|
||||
[
|
||||
'customAttributeMetadata' =>
|
||||
[
|
||||
'name' => 'customAttributeMetadata',
|
||||
'type' => 'CustomAttributeMetadata',
|
||||
'arguments' =>
|
||||
[
|
||||
'attributes' =>
|
||||
[
|
||||
'name' => 'attributes',
|
||||
'type' => 'AttributeInput',
|
||||
'description' => '',
|
||||
'required' => true,
|
||||
'isList' => true,
|
||||
'itemsRequired' => true,
|
||||
'defaultValue' => null
|
||||
],
|
||||
|
||||
],
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'resolver' => Magento\EavGraphQl\Model\Resolver\CustomAttributeMetadata::class,
|
||||
'description' => 'Returns the attribute type, given an attribute code and entity type',
|
||||
'cache' => [
|
||||
'cacheIdentity' =>
|
||||
Magento\EavGraphQl\Model\Resolver\CustomAttributeMetadata::class
|
||||
]
|
||||
],
|
||||
'products' => [
|
||||
'name' => 'products',
|
||||
'type' => 'Products',
|
||||
'arguments' =>
|
||||
[
|
||||
'search' =>
|
||||
[
|
||||
'name' => 'search',
|
||||
'type' => 'String',
|
||||
'description' => '',
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'itemsRequired' => false,
|
||||
'defaultValue' => null
|
||||
],
|
||||
|
||||
'filter' =>
|
||||
[
|
||||
'name' => 'filter',
|
||||
'type' => 'ProductFilterInput',
|
||||
'description' => '',
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'itemsRequired' => false,
|
||||
'defaultValue' => null
|
||||
],
|
||||
|
||||
'pageSize' =>
|
||||
[
|
||||
'name' => 'pageSize',
|
||||
'type' => 'Int',
|
||||
'description' => 'number of records to display',
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'itemsRequired' => false,
|
||||
'defaultValue' => 10
|
||||
],
|
||||
|
||||
'currentPage' =>
|
||||
[
|
||||
'name' => 'currentPage',
|
||||
'type' => 'Int',
|
||||
'description' => '',
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'itemsRequired' => false,
|
||||
'defaultValue' => 1
|
||||
],
|
||||
'sort' =>
|
||||
[
|
||||
'name' => 'sort',
|
||||
'type' => 'ProductSortInput',
|
||||
'description' => '',
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'itemsRequired' => false,
|
||||
'defaultValue' => null
|
||||
]
|
||||
],
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'resolver' => Magento\CatalogGraphQl\Model\Resolver\Products::class,
|
||||
'description' => 'comment for products fields'
|
||||
]
|
||||
]
|
||||
],
|
||||
'PriceAdjustmentDescriptionEnum' =>
|
||||
[
|
||||
'name' => 'PriceAdjustmentDescriptionEnum',
|
||||
'values' =>
|
||||
[
|
||||
'INCLUDED' =>
|
||||
[
|
||||
'name' => 'included',
|
||||
'value' => 'INCLUDED',
|
||||
'description' => 'price is included'
|
||||
],
|
||||
'EXCLUDED' =>
|
||||
[
|
||||
'name' => 'excluded',
|
||||
'value' => 'EXCLUDED',
|
||||
'description' => 'price is excluded'
|
||||
]
|
||||
],
|
||||
'description' => 'Description for enumType PriceAdjustmentDescriptionEnum'
|
||||
],
|
||||
'ProductLinks' =>
|
||||
[
|
||||
'name' => 'ProductLinks',
|
||||
'fields' =>
|
||||
[
|
||||
'sku' =>
|
||||
[
|
||||
'name' => 'sku',
|
||||
'type' => 'String',
|
||||
|
||||
'arguments' =>
|
||||
[
|
||||
],
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'resolver' => '',
|
||||
'description' => 'The identifier of the linked product',
|
||||
|
||||
],
|
||||
'link_type' =>
|
||||
[
|
||||
'name' => 'link_type',
|
||||
'type' => 'String',
|
||||
'arguments' =>
|
||||
[
|
||||
],
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'resolver' => '',
|
||||
'description' => '',
|
||||
|
||||
],
|
||||
'linked_product_sku' =>
|
||||
[
|
||||
'name' => 'linked_product_sku',
|
||||
'type' => 'String',
|
||||
'arguments' =>
|
||||
[
|
||||
],
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'resolver' => '',
|
||||
'description' => 'The SKU of the linked product',
|
||||
|
||||
],
|
||||
'linked_product_type' =>
|
||||
[
|
||||
'name' => 'linked_product_type',
|
||||
'type' => 'String',
|
||||
'arguments' =>
|
||||
[
|
||||
],
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'resolver' => '',
|
||||
'description' => '',
|
||||
|
||||
],
|
||||
'position' =>
|
||||
[
|
||||
'name' => 'position',
|
||||
'type' => 'Int',
|
||||
'arguments' =>
|
||||
[
|
||||
],
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'resolver' => '',
|
||||
'description' => 'The position within the list of product links',
|
||||
|
||||
]
|
||||
],
|
||||
'interfaces' =>
|
||||
[
|
||||
'ProductLinksInterface' =>
|
||||
[
|
||||
'interface' => 'ProductLinksInterface',
|
||||
'copyFields' => true,
|
||||
],
|
||||
],
|
||||
'description' => 'ProductLinks is an implementation of ProductLinksInterface.'
|
||||
],
|
||||
'ProductLinksInterface' =>
|
||||
[
|
||||
'name' => 'ProductLinksInterface',
|
||||
'fields' =>
|
||||
[
|
||||
'sku' =>
|
||||
[
|
||||
'name' => 'sku',
|
||||
'type' => 'String',
|
||||
|
||||
'arguments' =>
|
||||
[
|
||||
],
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'resolver' => '',
|
||||
'description' => 'The identifier of the linked product',
|
||||
|
||||
],
|
||||
'link_type' =>
|
||||
[
|
||||
'name' => 'link_type',
|
||||
'type' => 'String',
|
||||
'arguments' =>
|
||||
[
|
||||
],
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'resolver' => '',
|
||||
'description' => '',
|
||||
|
||||
],
|
||||
'linked_product_sku' =>
|
||||
[
|
||||
'name' => 'linked_product_sku',
|
||||
'type' => 'String',
|
||||
'arguments' =>
|
||||
[
|
||||
],
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'resolver' => '',
|
||||
'description' => 'The SKU of the linked product',
|
||||
|
||||
],
|
||||
'linked_product_type' =>
|
||||
[
|
||||
'name' => 'linked_product_type',
|
||||
'type' => 'String',
|
||||
'arguments' =>
|
||||
[
|
||||
],
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'resolver' => '',
|
||||
'description' => '',
|
||||
|
||||
],
|
||||
'position' =>
|
||||
[
|
||||
'name' => 'position',
|
||||
'type' => 'Int',
|
||||
'arguments' =>
|
||||
[
|
||||
],
|
||||
'required' => false,
|
||||
'isList' => false,
|
||||
'resolver' => '',
|
||||
'description' => 'The position within the list of product links',
|
||||
|
||||
]
|
||||
],
|
||||
'typeResolver' => Magento\CatalogGraphQl\Model\ProductLinkTypeResolverComposite::class,
|
||||
'description' => 'description for ProductLinksInterface'
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,48 @@
|
||||
type Query {
|
||||
placeholder: String @doc(description: "comment for placeholder.")
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
placeholder: String @doc(description: "comment for placeholder.")
|
||||
}
|
||||
|
||||
input FilterTypeInput @doc(description:"Comment for FilterTypeInput") {
|
||||
eq: String @doc(description:"Equal")
|
||||
from: String
|
||||
gt: String
|
||||
gteq: String
|
||||
in: [String]
|
||||
like: String
|
||||
lt: String
|
||||
lteq: String
|
||||
moreq: String
|
||||
neq: String
|
||||
notnull: String
|
||||
null: String
|
||||
to: String
|
||||
nin: [String]
|
||||
}
|
||||
|
||||
type SearchResultPageInfo
|
||||
@doc(description:"Comment for SearchResultPageInfo")
|
||||
{
|
||||
page_size: Int @doc(description:"Comment for page_size")
|
||||
current_page: Int @doc(description:"Comment for current_page")
|
||||
}
|
||||
|
||||
enum SortEnum @doc(description: "Comment for SortEnum.")
|
||||
{
|
||||
ASC @doc(description:"Ascending Order")
|
||||
DESC @doc(description:"Descending Order")
|
||||
}
|
||||
|
||||
interface ProductInterface {
|
||||
url_key: String @doc(description: "comment for url_key inside ProductInterface type.")
|
||||
url_path: String
|
||||
}
|
||||
|
||||
|
||||
type SimpleProduct {
|
||||
url_key: String @doc(description: "comment for url_key for simple product that implements [ProductInterface]")
|
||||
url_path: String
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
# Copyright © Magento, Inc. All rights reserved.
|
||||
# See COPYING.txt for license details.
|
||||
|
||||
type Query {
|
||||
products(
|
||||
search: String,
|
||||
filter: ProductFilterInput,
|
||||
pageSize: Int,
|
||||
currentPage: Int,
|
||||
sort: ProductSortInput
|
||||
): Products
|
||||
@resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Products")
|
||||
@doc(description: "comment for products fields")
|
||||
}
|
||||
|
||||
enum CurrencyEnum {
|
||||
AFN
|
||||
GBP
|
||||
EUR
|
||||
INR
|
||||
USD
|
||||
}
|
||||
|
||||
type Price {
|
||||
amount: Money
|
||||
adjustments: [PriceAdjustment]
|
||||
}
|
||||
|
||||
type PriceAdjustment {
|
||||
amount: Money
|
||||
code: PriceAdjustmentCodesEnum
|
||||
description: PriceAdjustmentDescriptionEnum
|
||||
}
|
||||
|
||||
enum PriceAdjustmentCodesEnum {
|
||||
TAX
|
||||
}
|
||||
|
||||
enum PriceAdjustmentDescriptionEnum {
|
||||
INCLUDED
|
||||
EXCLUDED
|
||||
}
|
||||
|
||||
enum PriceTypeEnum {
|
||||
FIXED
|
||||
PERCENT
|
||||
DYNAMIC
|
||||
}
|
||||
|
||||
type Money {
|
||||
value: Float
|
||||
currency: CurrencyEnum
|
||||
}
|
||||
|
||||
type ProductPrices {
|
||||
minimalPrice: Price
|
||||
maximalPrice: Price
|
||||
regularPrice: Price
|
||||
}
|
||||
|
||||
type ProductCategoryLinks {
|
||||
position: Int
|
||||
category_id: String
|
||||
}
|
||||
|
||||
|
||||
type ProductLinks implements ProductLinksInterface {
|
||||
sku: String
|
||||
link_type: String
|
||||
linked_product_sku: String
|
||||
linked_product_type: String
|
||||
position: Int
|
||||
}
|
||||
|
||||
interface ProductLinksInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\ProductLinkTypeResolverComposite") {
|
||||
sku: String
|
||||
link_type: String
|
||||
linked_product_sku: String
|
||||
linked_product_type: String
|
||||
position: Int
|
||||
}
|
||||
|
||||
type ProductTierPrices {
|
||||
customer_group_id: String
|
||||
qty: Float
|
||||
value: Float
|
||||
percentage_value: Float
|
||||
website_id: Float
|
||||
}
|
||||
|
||||
interface ProductInterface @typeResolver(class:"Magento\\CatalogGraphQl\\Model\\ProductInterfaceTypeResolverComposite") @doc(description: "comment for ProductInterface")
|
||||
{
|
||||
id: Int @doc(description: "comment for [ProductInterface].")
|
||||
name: String
|
||||
sku: String
|
||||
special_price: Float
|
||||
special_from_date: String
|
||||
attribute_set_id: Int
|
||||
tier_price: Float
|
||||
category_ids: [Int]
|
||||
updated_at: String
|
||||
country_of_manufacture: String
|
||||
type_id: String
|
||||
website_ids: [Int]
|
||||
category_links: [ProductCategoryLinks]
|
||||
product_links: [ProductLinksInterface]
|
||||
media_gallery_entries: [MediaGalleryEntry]
|
||||
tier_prices: [ProductTierPrices]
|
||||
price: ProductPrices
|
||||
manufacturer: Int
|
||||
}
|
||||
|
||||
interface PhysicalProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\ProductInterfaceTypeResolverComposite") @doc(description:"Comment for empty PhysicalProductInterface") {
|
||||
|
||||
}
|
||||
|
||||
|
||||
type CustomizableAreaOption implements CustomizableOptionInterface {
|
||||
value: CustomizableAreaValue
|
||||
product_sku: String
|
||||
title: String @doc(description:"Comment for title field for CustomizableAreaOption concrete type")
|
||||
required: Boolean
|
||||
sort_order: Int
|
||||
}
|
||||
|
||||
type CustomizableAreaValue {
|
||||
price: Float
|
||||
price_type: PriceTypeEnum
|
||||
sku: String
|
||||
max_characters: Int
|
||||
}
|
||||
|
||||
type CustomizableDateOption implements CustomizableOptionInterface {
|
||||
value: CustomizableDateValue
|
||||
product_sku: String
|
||||
title: String @doc(description:"This description should override interface comment.")
|
||||
required: Boolean
|
||||
sort_order: Int
|
||||
}
|
||||
|
||||
type CustomizableDateValue {
|
||||
price: Float
|
||||
price_type: PriceTypeEnum
|
||||
sku: String
|
||||
}
|
||||
|
||||
type CustomizableDropDownOption implements CustomizableOptionInterface {
|
||||
value: [CustomizableDropDownValue]
|
||||
required: Boolean @doc(description:"Comment for required field for CustomizableDropDownOption concrete type")
|
||||
}
|
||||
|
||||
type CustomizableDropDownValue {
|
||||
option_type_id: Int
|
||||
price: Float
|
||||
price_type: PriceTypeEnum
|
||||
sku: String
|
||||
title: String
|
||||
sort_order: Int
|
||||
}
|
||||
|
||||
type CustomizableFieldOption implements CustomizableOptionInterface {
|
||||
value: CustomizableFieldValue
|
||||
product_sku: String
|
||||
sort_order: Int @doc(description:"Comment for sort_order for CustomizableFieldOption concrete type")
|
||||
}
|
||||
|
||||
type CustomizableFieldValue {
|
||||
price: Float
|
||||
price_type: PriceTypeEnum
|
||||
sku: String
|
||||
max_characters: Int
|
||||
}
|
||||
|
||||
type CustomizableFileOption implements CustomizableOptionInterface {
|
||||
value: CustomizableFileValue
|
||||
product_sku: String
|
||||
}
|
||||
|
||||
type CustomizableFileValue {
|
||||
price: Float
|
||||
price_type: PriceTypeEnum
|
||||
sku: String
|
||||
file_extension: String
|
||||
image_size_x: Int
|
||||
image_size_y: Int
|
||||
}
|
||||
|
||||
interface CustomizableOptionInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\CustomizableOptionTypeResolver") {
|
||||
title: String @doc(description:"Comment for CustomizableOptionInterface")
|
||||
required: Boolean
|
||||
sort_order: Int
|
||||
}
|
||||
|
||||
interface CustomizableProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\ProductInterfaceTypeResolverComposite") {
|
||||
options: [CustomizableOptionInterface]
|
||||
}
|
||||
|
||||
type CustomizableRadioOption implements CustomizableOptionInterface {
|
||||
value: [CustomizableRadioValue]
|
||||
}
|
||||
|
||||
type CustomizableRadioValue {
|
||||
option_type_id: Int
|
||||
price: Float
|
||||
price_type: PriceTypeEnum
|
||||
sku: String
|
||||
title: String
|
||||
sort_order: Int
|
||||
}
|
||||
|
||||
type VirtualProduct implements ProductInterface, CustomizableProductInterface {
|
||||
}
|
||||
|
||||
type SimpleProduct implements ProductInterface, PhysicalProductInterface, CustomizableProductInterface @doc(description: "Comment for empty SimpleProduct type")
|
||||
{
|
||||
}
|
||||
|
||||
type SimpleProduct implements ProductInterface & PhysicalProductInterface & CustomizableProductInterface @doc(description: "Comment for empty SimpleProduct type")
|
||||
{
|
||||
}
|
||||
|
||||
type Products @doc(description:"Comment for Products") {
|
||||
items: [ProductInterface] @doc(description: "comment for items[Products].")
|
||||
page_info: SearchResultPageInfo @doc(description: "comment for page_info.")
|
||||
total_count: Int
|
||||
}
|
||||
|
||||
input ProductFilterInput @doc(description:"Comment for ProductFilterInput") {
|
||||
name: FilterTypeInput
|
||||
sku: FilterTypeInput @doc(description:"Comment for field_sku which is of type FilterTypeInput")
|
||||
description: FilterTypeInput
|
||||
short_description: FilterTypeInput
|
||||
price: FilterTypeInput
|
||||
special_price: FilterTypeInput
|
||||
special_from_date: FilterTypeInput
|
||||
special_to_date: FilterTypeInput
|
||||
weight: FilterTypeInput
|
||||
manufacturer: FilterTypeInput
|
||||
meta_title: FilterTypeInput
|
||||
meta_keyword: FilterTypeInput
|
||||
meta_description: FilterTypeInput
|
||||
image: FilterTypeInput
|
||||
small_image: FilterTypeInput
|
||||
thumbnail: FilterTypeInput
|
||||
tier_price: FilterTypeInput
|
||||
news_from_date: FilterTypeInput
|
||||
news_to_date: FilterTypeInput
|
||||
custom_design: FilterTypeInput
|
||||
custom_design_from: FilterTypeInput
|
||||
custom_design_to: FilterTypeInput
|
||||
custom_layout_update: FilterTypeInput
|
||||
page_layout: FilterTypeInput
|
||||
category_ids: FilterTypeInput
|
||||
options_container: FilterTypeInput
|
||||
required_options: FilterTypeInput
|
||||
has_options: FilterTypeInput
|
||||
image_label: FilterTypeInput
|
||||
small_image_label: FilterTypeInput
|
||||
thumbnail_label: FilterTypeInput
|
||||
created_at: FilterTypeInput
|
||||
updated_at: FilterTypeInput
|
||||
country_of_manufacture: FilterTypeInput
|
||||
custom_layout: FilterTypeInput
|
||||
gift_message_available: FilterTypeInput
|
||||
or: ProductFilterInput
|
||||
}
|
||||
|
||||
type ProductMediaGalleryEntriesContent @doc(description: "Comment for ProductMediaGalleryEntriesContent.") {
|
||||
base64_encoded_data: String
|
||||
type: String
|
||||
name: String
|
||||
}
|
||||
|
||||
type ProductMediaGalleryEntriesVideoContent {
|
||||
media_type: String
|
||||
video_provider: String
|
||||
video_url: String
|
||||
video_title: String
|
||||
video_description: String
|
||||
video_metadata: String
|
||||
}
|
||||
|
||||
input ProductSortInput @doc(description:"Input ProductSortInput") {
|
||||
name: SortEnum @doc(description:"Name")
|
||||
sku: SortEnum
|
||||
description: SortEnum
|
||||
short_description: SortEnum
|
||||
price: SortEnum
|
||||
special_price: SortEnum
|
||||
special_from_date: SortEnum
|
||||
special_to_date: SortEnum
|
||||
weight: SortEnum
|
||||
manufacturer: SortEnum
|
||||
meta_title: SortEnum
|
||||
meta_keyword: SortEnum
|
||||
meta_description: SortEnum
|
||||
image: SortEnum
|
||||
small_image: SortEnum
|
||||
thumbnail: SortEnum
|
||||
tier_price: SortEnum
|
||||
news_from_date: SortEnum
|
||||
news_to_date: SortEnum
|
||||
custom_design: SortEnum
|
||||
custom_design_from: SortEnum
|
||||
custom_design_to: SortEnum
|
||||
custom_layout_update: SortEnum
|
||||
page_layout: SortEnum
|
||||
category_ids: SortEnum
|
||||
options_container: SortEnum
|
||||
required_options: SortEnum
|
||||
has_options: SortEnum
|
||||
image_label: SortEnum
|
||||
small_image_label: SortEnum
|
||||
thumbnail_label: SortEnum
|
||||
created_at: SortEnum
|
||||
updated_at: SortEnum
|
||||
country_of_manufacture: SortEnum
|
||||
custom_layout: SortEnum
|
||||
gift_message_available: SortEnum
|
||||
}
|
||||
|
||||
type MediaGalleryEntry @doc(description: "Comment for MediaGalleryEntry type")
|
||||
{
|
||||
id: Int @doc(description: "id for MediaGalleryEntry")
|
||||
media_type: String
|
||||
label: String
|
||||
position: Int
|
||||
disabled: Boolean
|
||||
types: [String]
|
||||
file: String
|
||||
content: ProductMediaGalleryEntriesContent @doc(description: "Comment for ProductMediaGalleryEntriesContent on content field")
|
||||
video_content: ProductMediaGalleryEntriesVideoContent
|
||||
}
|
||||
|
||||
type EntityUrl {
|
||||
id: Int
|
||||
canonical_url: String
|
||||
type: UrlRewriteEntityTypeEnum
|
||||
}
|
||||
enum UrlRewriteEntityTypeEnum @doc(description: "Comment for empty Enum")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
type Query {
|
||||
customAttributeMetadata(attributes: [AttributeInput!]!): CustomAttributeMetadata @resolver(class: "Magento\\EavGraphQl\\Model\\Resolver\\CustomAttributeMetadata")
|
||||
@doc(description: "Returns the attribute type, given an attribute code and entity type") @cache(cacheTag: "cat_test", cacheIdentity: "Magento\\EavGraphQl\\Model\\Resolver\\CustomAttributeMetadata")
|
||||
}
|
||||
|
||||
type CustomAttributeMetadata {
|
||||
items: [Attribute] @doc(description: "An array of attributes")
|
||||
}
|
||||
|
||||
input AttributeInput @doc(description: "AttributeInput specifies the attribute_code and entity_type to search") {
|
||||
attribute_code: String @doc(description: "The unique identifier for an attribute code. This value should be in lowercase letters without spaces.")
|
||||
entity_type: String @doc(description: "The type of entity that defines the attribute")
|
||||
}
|
||||
|
||||
type Attribute @doc(description: "Attribute contains the attribute_type of the specified attribute_code and entity_type") {
|
||||
attribute_code: String @doc(description: "The unique identifier for an attribute code. This value should be in lowercase letters without spaces.")
|
||||
entity_type: String @doc(description: "The type of entity that defines the attribute")
|
||||
attribute_type: String @doc(description: "The data type of the attribute")
|
||||
}
|
||||
input FilterTypeInput @doc(description:"Comment for FilterTypeInput") {
|
||||
eq: String @doc(description:"Equal")
|
||||
from: String
|
||||
gt: String
|
||||
gteq: String
|
||||
in: [String]
|
||||
like: String
|
||||
lt: String
|
||||
lteq: String
|
||||
moreq: String
|
||||
neq: String
|
||||
notnull: String
|
||||
null: String
|
||||
to: String
|
||||
nin: [String]
|
||||
}
|
||||
|
||||
type SearchResultPageInfo
|
||||
@doc(description:"Comment for SearchResultPageInfo")
|
||||
{
|
||||
page_size: Int @doc(description:"Comment for page_size")
|
||||
current_page: Int @doc(description:"Comment for current_page")
|
||||
}
|
||||
|
||||
enum SortEnum @doc(description: "Comment for SortEnum.")
|
||||
{
|
||||
ASC @doc(description:"Ascending Order")
|
||||
DESC @doc(description:"Descending Order")
|
||||
}
|
||||
|
||||
interface ProductInterface {
|
||||
url_key: String @doc(description: "comment for url_key inside ProductInterface type.")
|
||||
url_path: String
|
||||
}
|
||||
|
||||
|
||||
type SimpleProduct {
|
||||
url_key: String @doc(description: "comment for url_key for simple product that implements [ProductInterface]")
|
||||
url_path: String
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
type Query {
|
||||
products(
|
||||
search: String,
|
||||
filter: ProductFilterInput,
|
||||
pageSize: Int =10 @doc(description: "number of records to display") ,
|
||||
currentPage: Int = 1,
|
||||
sort: ProductSortInput
|
||||
): Products
|
||||
@resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Products")
|
||||
@doc(description: "comment for products fields")
|
||||
}
|
||||
|
||||
enum CurrencyEnum {
|
||||
AFN
|
||||
GBP
|
||||
EUR
|
||||
INR
|
||||
USD
|
||||
}
|
||||
|
||||
type Price {
|
||||
amount: Money
|
||||
adjustments: [PriceAdjustment]
|
||||
}
|
||||
|
||||
type PriceAdjustment {
|
||||
amount: Money
|
||||
code: PriceAdjustmentCodesEnum
|
||||
description: PriceAdjustmentDescriptionEnum
|
||||
}
|
||||
|
||||
enum PriceAdjustmentCodesEnum {
|
||||
TAX
|
||||
}
|
||||
|
||||
enum PriceAdjustmentDescriptionEnum @doc(description: "Description for enumType PriceAdjustmentDescriptionEnum") {
|
||||
INCLUDED @doc(description: "price is included")
|
||||
EXCLUDED @doc(description: "price is excluded")
|
||||
}
|
||||
|
||||
enum PriceTypeEnum {
|
||||
FIXED
|
||||
PERCENT
|
||||
DYNAMIC
|
||||
}
|
||||
|
||||
type Money {
|
||||
value: Float
|
||||
currency: CurrencyEnum
|
||||
}
|
||||
|
||||
type ProductPrices {
|
||||
minimalPrice: Price
|
||||
maximalPrice: Price
|
||||
regularPrice: Price
|
||||
}
|
||||
|
||||
type ProductCategoryLinks {
|
||||
position: Int
|
||||
category_id: String
|
||||
}
|
||||
|
||||
|
||||
type ProductLinks implements ProductLinksInterface @doc(description: "ProductLinks is an implementation of ProductLinksInterface.") {
|
||||
|
||||
}
|
||||
|
||||
interface ProductLinksInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\ProductLinkTypeResolverComposite") @doc(description: "description for ProductLinksInterface") {
|
||||
sku: String @doc(description:"The identifier of the linked product")
|
||||
link_type: String
|
||||
linked_product_sku: String @doc(description:"The SKU of the linked product")
|
||||
linked_product_type: String
|
||||
position: Int @doc(description:"The position within the list of product links")
|
||||
}
|
||||
|
||||
type ProductTierPrices {
|
||||
customer_group_id: String
|
||||
qty: Float
|
||||
value: Float
|
||||
percentage_value: Float
|
||||
website_id: Float
|
||||
}
|
||||
|
||||
interface ProductInterface
|
||||
@typeResolver(class: "Magento\\CatalogGraphQl\\Model\\ProductInterfaceTypeResolverComposite")
|
||||
@doc(description: "comment for ProductInterface")
|
||||
{
|
||||
id: Int @doc(description: "comment for [ProductInterface].")
|
||||
name: String
|
||||
sku: String
|
||||
special_price: Float
|
||||
special_from_date: String
|
||||
attribute_set_id: Int
|
||||
tier_price: Float
|
||||
category_ids: [Int]
|
||||
updated_at: String
|
||||
country_of_manufacture: String
|
||||
type_id: String
|
||||
website_ids: [Int]
|
||||
category_links: [ProductCategoryLinks]
|
||||
product_links: [ProductLinksInterface]
|
||||
media_gallery_entries: [MediaGalleryEntry]
|
||||
tier_prices: [ProductTierPrices]
|
||||
price: ProductPrices
|
||||
manufacturer: Int
|
||||
}
|
||||
|
||||
interface PhysicalProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\ProductInterfaceTypeResolverComposite") @doc(description:"Comment for empty PhysicalProductInterface") {
|
||||
|
||||
}
|
||||
|
||||
|
||||
type CustomizableAreaOption implements CustomizableOptionInterface {
|
||||
value: CustomizableAreaValue
|
||||
product_sku: String
|
||||
title: String @doc(description:"Comment for title field for CustomizableAreaOption concrete type")
|
||||
required: Boolean
|
||||
sort_order: Int
|
||||
}
|
||||
|
||||
type CustomizableAreaValue {
|
||||
price: Float
|
||||
price_type: PriceTypeEnum
|
||||
sku: String
|
||||
max_characters: Int
|
||||
}
|
||||
|
||||
type CustomizableDateOption implements CustomizableOptionInterface {
|
||||
value: CustomizableDateValue
|
||||
product_sku: String
|
||||
title: String @doc(description:"This description should override interface comment.")
|
||||
required: Boolean
|
||||
sort_order: Int
|
||||
}
|
||||
|
||||
type CustomizableDateValue {
|
||||
price: Float
|
||||
price_type: PriceTypeEnum
|
||||
sku: String
|
||||
}
|
||||
|
||||
type CustomizableDropDownOption implements CustomizableOptionInterface {
|
||||
value: [CustomizableDropDownValue]
|
||||
required: Boolean @doc(description:"Comment for required field for CustomizableDropDownOption concrete type")
|
||||
}
|
||||
|
||||
type CustomizableDropDownValue {
|
||||
option_type_id: Int
|
||||
price: Float
|
||||
price_type: PriceTypeEnum
|
||||
sku: String
|
||||
title: String
|
||||
sort_order: Int
|
||||
}
|
||||
|
||||
type CustomizableFieldOption implements CustomizableOptionInterface {
|
||||
value: CustomizableFieldValue
|
||||
product_sku: String
|
||||
sort_order: Int @doc(description:"Comment for sort_order for CustomizableFieldOption concrete type")
|
||||
}
|
||||
|
||||
type CustomizableFieldValue {
|
||||
price: Float
|
||||
price_type: PriceTypeEnum
|
||||
sku: String
|
||||
max_characters: Int
|
||||
}
|
||||
|
||||
type CustomizableFileOption implements CustomizableOptionInterface {
|
||||
value: CustomizableFileValue
|
||||
product_sku: String
|
||||
}
|
||||
|
||||
type CustomizableFileValue {
|
||||
price: Float
|
||||
price_type: PriceTypeEnum
|
||||
sku: String
|
||||
file_extension: String
|
||||
image_size_x: Int
|
||||
image_size_y: Int
|
||||
}
|
||||
|
||||
interface CustomizableOptionInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\CustomizableOptionTypeResolver") {
|
||||
title: String @doc(description:"Comment for CustomizableOptionInterface")
|
||||
required: Boolean
|
||||
sort_order: Int
|
||||
}
|
||||
|
||||
interface CustomizableProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\ProductInterfaceTypeResolverComposite") {
|
||||
options: [CustomizableOptionInterface]
|
||||
}
|
||||
|
||||
type CustomizableRadioOption implements CustomizableOptionInterface {
|
||||
value: [CustomizableRadioValue]
|
||||
}
|
||||
|
||||
type CustomizableRadioValue {
|
||||
option_type_id: Int
|
||||
price: Float
|
||||
price_type: PriceTypeEnum
|
||||
sku: String
|
||||
title: String
|
||||
sort_order: Int
|
||||
}
|
||||
|
||||
type VirtualProduct implements ProductInterface, CustomizableProductInterface {
|
||||
}
|
||||
|
||||
type SimpleProduct implements ProductInterface, PhysicalProductInterface, CustomizableProductInterface
|
||||
@doc(description: "Comment for empty SimpleProduct type")
|
||||
{
|
||||
}
|
||||
|
||||
type Products @doc(description:"Comment for Products") {
|
||||
items: [ProductInterface] @doc(description: "comment for items[Products].")
|
||||
page_info: SearchResultPageInfo @doc(description: "comment for page_info.")
|
||||
total_count: Int
|
||||
}
|
||||
|
||||
input ProductFilterInput @doc(description:"Comment for ProductFilterInput") {
|
||||
name: FilterTypeInput
|
||||
sku: FilterTypeInput @doc(description:"Comment for field_sku which is of type FilterTypeInput")
|
||||
description: FilterTypeInput
|
||||
short_description: FilterTypeInput
|
||||
price: FilterTypeInput
|
||||
special_price: FilterTypeInput
|
||||
special_from_date: FilterTypeInput
|
||||
special_to_date: FilterTypeInput
|
||||
weight: FilterTypeInput
|
||||
manufacturer: FilterTypeInput
|
||||
meta_title: FilterTypeInput
|
||||
meta_keyword: FilterTypeInput
|
||||
meta_description: FilterTypeInput
|
||||
image: FilterTypeInput
|
||||
small_image: FilterTypeInput
|
||||
thumbnail: FilterTypeInput
|
||||
tier_price: FilterTypeInput
|
||||
news_from_date: FilterTypeInput
|
||||
news_to_date: FilterTypeInput
|
||||
custom_design: FilterTypeInput
|
||||
custom_design_from: FilterTypeInput
|
||||
custom_design_to: FilterTypeInput
|
||||
custom_layout_update: FilterTypeInput
|
||||
page_layout: FilterTypeInput
|
||||
category_ids: FilterTypeInput
|
||||
options_container: FilterTypeInput
|
||||
required_options: FilterTypeInput
|
||||
has_options: FilterTypeInput
|
||||
image_label: FilterTypeInput
|
||||
small_image_label: FilterTypeInput
|
||||
thumbnail_label: FilterTypeInput
|
||||
created_at: FilterTypeInput
|
||||
updated_at: FilterTypeInput
|
||||
country_of_manufacture: FilterTypeInput
|
||||
custom_layout: FilterTypeInput
|
||||
gift_message_available: FilterTypeInput
|
||||
or: ProductFilterInput
|
||||
}
|
||||
|
||||
type ProductMediaGalleryEntriesContent @doc(description: "Comment for ProductMediaGalleryEntriesContent.") {
|
||||
base64_encoded_data: String
|
||||
type: String
|
||||
name: String
|
||||
}
|
||||
|
||||
type ProductMediaGalleryEntriesVideoContent {
|
||||
media_type: String
|
||||
video_provider: String
|
||||
video_url: String
|
||||
video_title: String
|
||||
video_description: String
|
||||
video_metadata: String
|
||||
}
|
||||
|
||||
input ProductSortInput @doc(description:"Input ProductSortInput") {
|
||||
name: SortEnum @doc(description:"Name")
|
||||
sku: SortEnum
|
||||
description: SortEnum
|
||||
short_description: SortEnum
|
||||
price: SortEnum
|
||||
special_price: SortEnum
|
||||
special_from_date: SortEnum
|
||||
special_to_date: SortEnum
|
||||
weight: SortEnum
|
||||
manufacturer: SortEnum
|
||||
meta_title: SortEnum
|
||||
meta_keyword: SortEnum
|
||||
meta_description: SortEnum
|
||||
image: SortEnum
|
||||
small_image: SortEnum
|
||||
thumbnail: SortEnum
|
||||
tier_price: SortEnum
|
||||
news_from_date: SortEnum
|
||||
news_to_date: SortEnum
|
||||
custom_design: SortEnum
|
||||
custom_design_from: SortEnum
|
||||
custom_design_to: SortEnum
|
||||
custom_layout_update: SortEnum
|
||||
page_layout: SortEnum
|
||||
category_ids: SortEnum
|
||||
options_container: SortEnum
|
||||
required_options: SortEnum
|
||||
has_options: SortEnum
|
||||
image_label: SortEnum
|
||||
small_image_label: SortEnum
|
||||
thumbnail_label: SortEnum
|
||||
created_at: SortEnum
|
||||
updated_at: SortEnum
|
||||
country_of_manufacture: SortEnum
|
||||
custom_layout: SortEnum
|
||||
gift_message_available: SortEnum
|
||||
}
|
||||
|
||||
type MediaGalleryEntry
|
||||
@doc(description: "Comment for MediaGalleryEntry type")
|
||||
{
|
||||
id: Int @doc(description: "id for MediaGalleryEntry")
|
||||
media_type: String
|
||||
label: String
|
||||
position: Int
|
||||
disabled: Boolean
|
||||
types: [String]
|
||||
file: String
|
||||
content: ProductMediaGalleryEntriesContent @doc(description: "Comment for ProductMediaGalleryEntriesContent on content field")
|
||||
video_content: ProductMediaGalleryEntriesVideoContent
|
||||
}
|
||||
|
||||
type EntityUrl {
|
||||
id: Int
|
||||
canonical_url: String
|
||||
type: UrlRewriteEntityTypeEnum
|
||||
}
|
||||
enum UrlRewriteEntityTypeEnum @doc(description: "Comment for empty Enum")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
+4278
File diff suppressed because it is too large
Load Diff
+4278
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user