|
@@ 186-204 (lines=19) @@
|
| 183 |
|
* |
| 184 |
|
* @return ObjectDefinition |
| 185 |
|
*/ |
| 186 |
|
private function createChildNamespace(ObjectDefinitionInterface $parent, $name, $typeName, Endpoint $endpoint): ObjectDefinition |
| 187 |
|
{ |
| 188 |
|
$child = new FieldDefinition(); |
| 189 |
|
$child->setName($name); |
| 190 |
|
$child->setResolver(EmptyObjectResolver::class); |
| 191 |
|
|
| 192 |
|
$type = new ObjectDefinition(); |
| 193 |
|
$type->setName($typeName); |
| 194 |
|
if ($endpoint->hasType($type->getName())) { |
| 195 |
|
$type = $endpoint->getType($type->getName()); |
| 196 |
|
} else { |
| 197 |
|
$endpoint->add($type); |
| 198 |
|
} |
| 199 |
|
|
| 200 |
|
$child->setType($type->getName()); |
| 201 |
|
$parent->addField($child); |
| 202 |
|
|
| 203 |
|
return $type; |
| 204 |
|
} |
| 205 |
|
|
| 206 |
|
/** |
| 207 |
|
* @param string $rootType Class of the root type to create QueryDefinition or MutationDefinition |
|
@@ 214-232 (lines=19) @@
|
| 211 |
|
* |
| 212 |
|
* @return ExecutableDefinitionInterface |
| 213 |
|
*/ |
| 214 |
|
private function createRootNamespace($rootType, $name, $typeName, Endpoint $endpoint): ExecutableDefinitionInterface |
| 215 |
|
{ |
| 216 |
|
/** @var ExecutableDefinitionInterface $rootDefinition */ |
| 217 |
|
$rootDefinition = new $rootType(); |
| 218 |
|
$rootDefinition->setName($name); |
| 219 |
|
$rootDefinition->setResolver(EmptyObjectResolver::class); |
| 220 |
|
|
| 221 |
|
$type = new ObjectDefinition(); |
| 222 |
|
$type->setName($typeName); |
| 223 |
|
if ($endpoint->hasType($type->getName())) { |
| 224 |
|
$type = $endpoint->getType($type->getName()); |
| 225 |
|
} else { |
| 226 |
|
$endpoint->add($type); |
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
$rootDefinition->setType($type->getName()); |
| 230 |
|
|
| 231 |
|
return $rootDefinition; |
| 232 |
|
} |
| 233 |
|
} |
| 234 |
|
|