Skip to content

Commit b54639b

Browse files
Moving override call upstream
1 parent 493eabf commit b54639b

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

app/code/Magento/GraphQl/Controller/GraphQl.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\GraphQl\Controller;
99

10-
use GraphQL\Type\Definition\Type as GraphQLType;
1110
use Magento\Framework\App\FrontControllerInterface;
1211
use Magento\Framework\App\ObjectManager;
1312
use Magento\Framework\App\Request\Http;
@@ -20,9 +19,6 @@
2019
use Magento\Framework\GraphQl\Query\QueryProcessor;
2120
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
2221
use Magento\Framework\GraphQl\Schema\SchemaGeneratorInterface;
23-
use Magento\Framework\GraphQl\Type\Definition\FloatType;
24-
use Magento\Framework\GraphQl\Type\Definition\IntType;
25-
use Magento\Framework\GraphQl\Type\Definition\StringType;
2622
use Magento\Framework\Serialize\SerializerInterface;
2723
use Magento\Framework\Webapi\Response;
2824
use Magento\GraphQl\Helper\Query\Logger\LogData;
@@ -167,8 +163,6 @@ public function dispatch(RequestInterface $request): ResponseInterface
167163

168164
$schema = null;
169165
try {
170-
$this->overrideStandardGraphQLTypes();
171-
172166
/** @var Http $request */
173167
$this->requestProcessor->validateRequest($request);
174168

@@ -205,23 +199,6 @@ public function dispatch(RequestInterface $request): ResponseInterface
205199
return $this->httpResponse;
206200
}
207201

208-
/**
209-
* Replace the standard type definitions with ones that know how to cast input values
210-
*/
211-
private function overrideStandardGraphQLTypes(): void
212-
{
213-
$standardTypes = GraphQLType::getStandardTypes();
214-
215-
$intType = new IntType($standardTypes[GraphQLType::INT]->config);
216-
$floatType = new FloatType($standardTypes[GraphQLType::FLOAT]->config);
217-
$stringType = new StringType($standardTypes[GraphQLType::STRING]->config);
218-
\GraphQL\GraphQL::overrideStandardTypes([
219-
GraphQLType::INT => $intType,
220-
GraphQLType::FLOAT => $floatType,
221-
GraphQLType::STRING => $stringType
222-
]);
223-
}
224-
225202
/**
226203
* Get data from request body or query string
227204
*

lib/internal/Magento/Framework/GraphQlSchemaStitching/GraphQlReader.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77

88
namespace Magento\Framework\GraphQlSchemaStitching;
99

10+
use GraphQL\GraphQL;
1011
use GraphQL\Type\Definition\ScalarType;
12+
use GraphQL\Type\Definition\Type as GraphQLType;
1113
use GraphQL\Utils\BuildSchema;
1214
use Magento\Framework\Component\ComponentRegistrar;
1315
use Magento\Framework\Config\FileResolverInterface;
1416
use Magento\Framework\Config\ReaderInterface;
17+
use Magento\Framework\GraphQl\Type\Definition\FloatType;
18+
use Magento\Framework\GraphQl\Type\Definition\IntType;
19+
use Magento\Framework\GraphQl\Type\Definition\StringType;
1520
use Magento\Framework\GraphQlSchemaStitching\GraphQlReader\TypeMetaReaderInterface as TypeReaderComposite;
1621
use Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\InterfaceType;
1722

@@ -70,6 +75,7 @@ public function __construct(
7075
$this->typeReader = $typeReader;
7176
$this->defaultScope = $defaultScope;
7277
$this->fileName = $fileName;
78+
$this->overrideStandardGraphQLTypes();
7379
}
7480

7581
/**
@@ -343,4 +349,19 @@ private function addModuleNameToTypes(array $source, string $filePath): array
343349

344350
return $source;
345351
}
352+
353+
354+
/**
355+
* Replace the standard type definitions with ones that know how to cast input values
356+
*/
357+
private function overrideStandardGraphQLTypes(): void
358+
{
359+
$standardTypes = GraphQLType::getStandardTypes();
360+
361+
GraphQL::overrideStandardTypes([
362+
GraphQLType::INT => new IntType($standardTypes[GraphQLType::INT]->config),
363+
GraphQLType::FLOAT => new FloatType($standardTypes[GraphQLType::FLOAT]->config),
364+
GraphQLType::STRING => new StringType($standardTypes[GraphQLType::STRING]->config)
365+
]);
366+
}
346367
}

0 commit comments

Comments
 (0)