Skip to content

Commit 9805936

Browse files
committed
v1.0.4:
- Added support for the changes in php-graphql-client v1.5 - Modified RootQueryObject to get generated with an OBJECT_NAME of '' instead of 'query' - Modified the existing construction of the QueryObject to accommodate for existing RootQueryObjects with OBJECT_NAME of 'query' to avoid breaking backwards compatibility
1 parent bbad2f4 commit 9805936

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"bin": ["bin/generate_schema_objects"],
3636
"require": {
3737
"php": "^7.1",
38-
"gmostafa/php-graphql-client": "^1.0"
38+
"gmostafa/php-graphql-client": "^1.5"
3939
},
4040
"require-dev": {
4141
"phpunit/phpunit": "^7.5|^8.0",

src/SchemaGenerator/CodeGenerator/QueryObjectClassBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(string $writeDir, string $objectName, string $namesp
3333

3434
// Special case for handling root query object
3535
if ($objectName === QueryObject::ROOT_QUERY_OBJECT_NAME) {
36-
$objectName = 'query';
36+
$objectName = '';
3737
}
3838
$this->classFile->addConstant('OBJECT_NAME', $objectName);
3939
}

src/SchemaObject/QueryObject.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ abstract class QueryObject extends AbstractQueryBuilder
3636
*/
3737
public function __construct(string $fieldName = '')
3838
{
39-
$queryObject = !empty($fieldName) ? $fieldName : static::OBJECT_NAME;
39+
// Maintain backwards compatibility for generated RootQueryObjects by converting OBJECT_NAME 'query' to '' when encountered
40+
// TODO: Remove this when bumping up one major version
41+
$objectName = static::OBJECT_NAME === 'query' ? '' : static::OBJECT_NAME;
42+
$queryObject = !empty($fieldName) ? $fieldName : $objectName;
4043
parent::__construct($queryObject);
4144
}
4245

tests/files_expected/query_objects/RootQueryObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
class RootQueryObject extends QueryObject
88
{
9-
const OBJECT_NAME = "query";
9+
const OBJECT_NAME = "";
1010
}

0 commit comments

Comments
 (0)