56
56
* }
57
57
* ]);
58
58
*/
59
- class ObjectType extends Type implements OutputType, CompositeType, NullableType, NamedType, ImplementingType
59
+ class ObjectType extends TypeWithFields implements OutputType, CompositeType, NullableType, NamedType, ImplementingType
60
60
{
61
61
/** @var ObjectTypeDefinitionNode|null */
62
62
public $ astNode ;
@@ -67,13 +67,6 @@ class ObjectType extends Type implements OutputType, CompositeType, NullableType
67
67
/** @var ?callable */
68
68
public $ resolveFieldFn ;
69
69
70
- /**
71
- * Lazily initialized.
72
- *
73
- * @var FieldDefinition[]
74
- */
75
- private $ fields ;
76
-
77
70
/**
78
71
* Lazily initialized.
79
72
*
@@ -124,49 +117,6 @@ public static function assertObjectType($type): self
124
117
return $ type ;
125
118
}
126
119
127
- /**
128
- * @throws InvariantViolation
129
- */
130
- public function getField (string $ name ): FieldDefinition
131
- {
132
- if (! isset ($ this ->fields )) {
133
- $ this ->initializeFields ();
134
- }
135
-
136
- Utils::invariant (isset ($ this ->fields [$ name ]), 'Field "%s" is not defined for type "%s" ' , $ name , $ this ->name );
137
-
138
- return $ this ->fields [$ name ];
139
- }
140
-
141
- public function hasField (string $ name ): bool
142
- {
143
- if (! isset ($ this ->fields )) {
144
- $ this ->initializeFields ();
145
- }
146
-
147
- return isset ($ this ->fields [$ name ]);
148
- }
149
-
150
- /**
151
- * @return FieldDefinition[]
152
- *
153
- * @throws InvariantViolation
154
- */
155
- public function getFields (): array
156
- {
157
- if (! isset ($ this ->fields )) {
158
- $ this ->initializeFields ();
159
- }
160
-
161
- return $ this ->fields ;
162
- }
163
-
164
- protected function initializeFields (): void
165
- {
166
- $ fields = $ this ->config ['fields ' ] ?? [];
167
- $ this ->fields = FieldDefinition::defineFieldMap ($ this , $ fields );
168
- }
169
-
170
120
public function implementsInterface (InterfaceType $ interfaceType ): bool
171
121
{
172
122
if (! isset ($ this ->interfaceMap )) {
0 commit comments