Skip to content

Commit 63229d7

Browse files
committed
remove __typename from internal fields of GraphQLObjectType and enable it in the executor
1 parent cf461cb commit 63229d7

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

src/Execution/Executor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ private function getFieldDef(Schema $schema, GraphQLObjectType $parentType, stri
471471
$TypeMetaFieldDef = null;
472472
require __DIR__."/../Introspection/Introspection.php";
473473
return $TypeMetaFieldDef;
474-
} else if ($fieldName === "__typename" && $schema->getQueryType() === $parentType) {
474+
} else if ($fieldName === "__typename") {
475475
$TypeNameMetaFieldDef = null;
476476
require __DIR__."/../Introspection/Introspection.php";
477477
return $TypeNameMetaFieldDef;

src/Types/GraphQLObjectType.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class GraphQLObjectType extends GraphQLType
1212
protected $description;
1313

1414
private $fields;
15-
private $internalFields;
1615
private $interfaces;
1716
private $isTypeOfFn;
1817

@@ -22,15 +21,6 @@ public function __construct(string $type, string $description, \Closure $fields,
2221
$this->description = $description;
2322

2423
$this->fields = $fields;
25-
26-
// create internal fields
27-
$this->internalFields = [
28-
"__typename" => new GraphQLTypeField("__typename", new GraphQLNonNull(new GraphQLString()), "Name of the type of the object", function () use ($type) {
29-
return $type;
30-
})
31-
];
32-
33-
3424
$this->interfaces = $interfaces ?? [];
3525
$this->isTypeOfFn = $isTypeOfFn ?? function ($value, $contextValue, $info) {
3626
// if $value is array, check if all keys match
@@ -82,8 +72,6 @@ public function getFields(): array
8272
foreach ($allFields as $field) {
8373
$fields[$field->getName()] = $field;
8474
}
85-
86-
$fields = array_merge($fields, $this->internalFields);
8775
return $fields;
8876
}
8977

0 commit comments

Comments
 (0)