Passed
Pull Request — master (#132)
by Christoffer
04:13 queued 01:55
created

InterfaceType::afterConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Digia\GraphQL\Type\Definition;
4
5
use Digia\GraphQL\Config\ConfigObject;
6
use Digia\GraphQL\Language\Node\InterfaceTypeDefinitionNode;
7
use Digia\GraphQL\Language\Node\NodeAwareInterface;
8
use Digia\GraphQL\Language\Node\NodeTrait;
9
use function Digia\GraphQL\Util\invariant;
10
11
/**
12
 * Interface Type Definition
13
 *
14
 * When a field can return one of a heterogeneous set of types, a Interface type
15
 * is used to describe what types are possible, what fields are in common across
16
 * all types, as well as a function to determine which type is actually used
17
 * when the field is resolved.
18
 *
19
 * Example:
20
 *     $EntityType = GraphQLInterfaceType([
21
 *       'name' => 'Entity',
22
 *       'fields' => [
23
 *         'name' => ['type' => GraphQLString()]
24
 *       ]
25
 *     ]);
26
 */
27
class InterfaceType extends ConfigObject implements NamedTypeInterface, AbstractTypeInterface,
28
    CompositeTypeInterface, OutputTypeInterface, NodeAwareInterface
29
{
30
    use NameTrait;
31
    use DescriptionTrait;
32
    use FieldsTrait;
33
    use NodeTrait;
34
    use ExtensionASTNodesTrait;
35
    use ResolveTypeTrait;
36
37
    /**
38
     * @inheritdoc
39
     */
40
    protected function afterConfig(): void
41
    {
42
        invariant(null !== $this->getName(), 'Must provide name.');
43
    }
44
}
45