Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/class-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ Usage example:
types?: Types|null,
scalarOverrides?: array<ScalarType>|null,
directives?: array<Directive>|null,
schemaDirectives?: array<DirectiveNode>|null,
typeLoader?: TypeLoader|null,
assumeValid?: bool|null,
astNode?: SchemaDefinitionNode|null,
Expand Down Expand Up @@ -951,6 +952,24 @@ function getDirectives(): ?array
function setDirectives(?array $directives): self
```

```php
/**
* @return array<DirectiveNode>
*
* @api
*/
function getSchemaDirectives(): array
```

```php
/**
* @param array<DirectiveNode>|null $directives
*
* @api
*/
function setSchemaDirectives(?array $directives): self
```

```php
/**
* @return callable|null $typeLoader
Expand Down Expand Up @@ -3081,7 +3100,10 @@ All sorting options sort alphabetically. If not given or `false`, the original s
sortFields?: bool,
sortInputFields?: bool,
sortTypes?: bool,
includeAppliedDirectives?: bool,
}
@phpstan-type AppliedDirectiveDefinition Schema|Argument|FieldDefinition|InputObjectField|EnumValueDefinition|ScalarType|ObjectType|InterfaceType|UnionType|EnumType|InputObjectType
@phpstan-type AppliedDirectiveAstNode SchemaDefinitionNode|SchemaExtensionNode|InputValueDefinitionNode|FieldDefinitionNode|EnumValueDefinitionNode|ScalarTypeDefinitionNode|ScalarTypeExtensionNode|ObjectTypeDefinitionNode|ObjectTypeExtensionNode|InterfaceTypeDefinitionNode|InterfaceTypeExtensionNode|UnionTypeDefinitionNode|UnionTypeExtensionNode|EnumTypeDefinitionNode|EnumTypeExtensionNode|InputObjectTypeDefinitionNode|InputObjectTypeExtensionNode
```

@see \GraphQL\Tests\Utils\SchemaPrinterTest
Expand Down
7 changes: 7 additions & 0 deletions src/Type/Definition/Argument.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace GraphQL\Type\Definition;

use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\InputValueDefinitionNode;
use GraphQL\Type\Schema;
use GraphQL\Utils\Utils;
Expand All @@ -15,6 +16,7 @@
* defaultValue?: mixed,
* description?: string|null,
* deprecationReason?: string|null,
* directives?: array<DirectiveNode>|null,
* astNode?: InputValueDefinitionNode|null
* }
* @phpstan-type ArgumentConfig array{
Expand All @@ -23,6 +25,7 @@
* defaultValue?: mixed,
* description?: string|null,
* deprecationReason?: string|null,
* directives?: array<DirectiveNode>|null,
* astNode?: InputValueDefinitionNode|null
* }
* @phpstan-type ArgumentListConfig iterable<ArgumentConfig|ArgumentType>|iterable<UnnamedArgumentConfig>
Expand All @@ -43,6 +46,9 @@ class Argument

public ?InputValueDefinitionNode $astNode;

/** @var array<DirectiveNode> */
public array $directives;

/** @phpstan-var ArgumentConfig */
public array $config;

Expand All @@ -55,6 +61,7 @@ public function __construct(array $config)
$this->deprecationReason = $config['deprecationReason'] ?? null;
// Do nothing for type, it is lazy loaded in getType()
$this->astNode = $config['astNode'] ?? null;
$this->directives = $config['directives'] ?? [];

$this->config = $config;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Type/Definition/CustomScalarType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use GraphQL\Error\Error;
use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\ScalarTypeDefinitionNode;
use GraphQL\Language\AST\ScalarTypeExtensionNode;
Expand All @@ -18,6 +19,7 @@
* serialize?: callable(mixed): mixed,
* parseValue: callable(mixed): mixed,
* parseLiteral: callable(ValueNode&Node, array<string, mixed>|null): mixed,
* directives?: array<DirectiveNode>|null,
* specifiedByURL?: string|null,
* astNode?: ScalarTypeDefinitionNode|null,
* extensionASTNodes?: array<ScalarTypeExtensionNode>|null
Expand All @@ -28,6 +30,7 @@
* serialize: callable(mixed): mixed,
* parseValue?: callable(mixed): mixed,
* parseLiteral?: callable(ValueNode&Node, array<string, mixed>|null): mixed,
* directives?: array<DirectiveNode>|null,
* specifiedByURL?: string|null,
* astNode?: ScalarTypeDefinitionNode|null,
* extensionASTNodes?: array<ScalarTypeExtensionNode>|null
Expand Down
7 changes: 7 additions & 0 deletions src/Type/Definition/EnumType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use GraphQL\Error\Error;
use GraphQL\Error\InvariantViolation;
use GraphQL\Error\SerializationError;
use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\EnumTypeDefinitionNode;
use GraphQL\Language\AST\EnumTypeExtensionNode;
use GraphQL\Language\AST\EnumValueDefinitionNode;
Expand All @@ -22,13 +23,15 @@
* value?: mixed,
* deprecationReason?: string|null,
* description?: string|null,
* directives?: array<DirectiveNode>|null,
* astNode?: EnumValueDefinitionNode|null
* }
* @phpstan-type EnumValues iterable<string, PartialEnumValueConfig>|iterable<string, mixed>|iterable<int, string>
* @phpstan-type EnumTypeConfig array{
* name?: string|null,
* description?: string|null,
* values: EnumValues|callable(): EnumValues,
* directives?: array<DirectiveNode>|null,
* astNode?: EnumTypeDefinitionNode|null,
* extensionASTNodes?: array<EnumTypeExtensionNode>|null
* }
Expand All @@ -42,6 +45,9 @@ class EnumType extends Type implements InputType, OutputType, LeafType, Nullable
/** @var array<EnumTypeExtensionNode> */
public array $extensionASTNodes;

/** @var array<DirectiveNode> */
public array $directives;

/** @phpstan-var EnumTypeConfig */
public array $config;

Expand Down Expand Up @@ -73,6 +79,7 @@ public function __construct(array $config)
$this->description = $config['description'] ?? null;
$this->astNode = $config['astNode'] ?? null;
$this->extensionASTNodes = $config['extensionASTNodes'] ?? [];
$this->directives = $config['directives'] ?? [];

$this->config = $config;
}
Expand Down
6 changes: 6 additions & 0 deletions src/Type/Definition/EnumValueDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace GraphQL\Type\Definition;

use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\EnumValueDefinitionNode;

/**
Expand All @@ -10,6 +11,7 @@
* value?: mixed,
* deprecationReason?: string|null,
* description?: string|null,
* directives?: array<DirectiveNode>|null,
* astNode?: EnumValueDefinitionNode|null
* }
*/
Expand All @@ -26,6 +28,9 @@ class EnumValueDefinition

public ?EnumValueDefinitionNode $astNode;

/** @var array<DirectiveNode> */
public array $directives;

/** @phpstan-var EnumValueConfig */
public array $config;

Expand All @@ -37,6 +42,7 @@ public function __construct(array $config)
$this->deprecationReason = $config['deprecationReason'] ?? null;
$this->description = $config['description'] ?? null;
$this->astNode = $config['astNode'] ?? null;
$this->directives = $config['directives'] ?? [];

$this->config = $config;
}
Expand Down
7 changes: 7 additions & 0 deletions src/Type/Definition/FieldDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use GraphQL\Error\InvariantViolation;
use GraphQL\Executor\Executor;
use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\FieldDefinitionNode;
use GraphQL\Type\Schema;
use GraphQL\Utils\Utils;
Expand All @@ -27,6 +28,7 @@
* description?: string|null,
* visible?: VisibilityFn|bool,
* deprecationReason?: string|null,
* directives?: array<DirectiveNode>|null,
* astNode?: FieldDefinitionNode|null,
* complexity?: ComplexityFn|null
* }
Expand All @@ -38,6 +40,7 @@
* description?: string|null,
* visible?: VisibilityFn|bool,
* deprecationReason?: string|null,
* directives?: array<DirectiveNode>|null,
* astNode?: FieldDefinitionNode|null,
* complexity?: ComplexityFn|null
* }
Expand Down Expand Up @@ -90,6 +93,9 @@ class FieldDefinition

public ?FieldDefinitionNode $astNode;

/** @var array<DirectiveNode> */
public array $directives;

/**
* @var callable|null
*
Expand Down Expand Up @@ -120,6 +126,7 @@ public function __construct(array $config)
$this->visible = $config['visible'] ?? true;
$this->deprecationReason = $config['deprecationReason'] ?? null;
$this->astNode = $config['astNode'] ?? null;
$this->directives = $config['directives'] ?? [];
$this->complexityFn = $config['complexity'] ?? null;

$this->config = $config;
Expand Down
7 changes: 7 additions & 0 deletions src/Type/Definition/InputObjectField.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace GraphQL\Type\Definition;

use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\InputValueDefinitionNode;
use GraphQL\Type\Schema;
use GraphQL\Utils\Utils;
Expand All @@ -15,6 +16,7 @@
* defaultValue?: mixed,
* description?: string|null,
* deprecationReason?: string|null,
* directives?: array<DirectiveNode>|null,
* astNode?: InputValueDefinitionNode|null
* }
* @phpstan-type UnnamedInputObjectFieldConfig array{
Expand All @@ -23,6 +25,7 @@
* defaultValue?: mixed,
* description?: string|null,
* deprecationReason?: string|null,
* directives?: array<DirectiveNode>|null,
* astNode?: InputValueDefinitionNode|null
* }
*/
Expand All @@ -42,6 +45,9 @@ class InputObjectField

public ?InputValueDefinitionNode $astNode;

/** @var array<DirectiveNode> */
public array $directives;

/** @phpstan-var InputObjectFieldConfig */
public array $config;

Expand All @@ -54,6 +60,7 @@ public function __construct(array $config)
$this->deprecationReason = $config['deprecationReason'] ?? null;
// Do nothing for type, it is lazy loaded in getType()
$this->astNode = $config['astNode'] ?? null;
$this->directives = $config['directives'] ?? [];

$this->config = $config;
}
Expand Down
7 changes: 6 additions & 1 deletion src/Type/Definition/InputObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use GraphQL\Error\Error;
use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\InputObjectTypeDefinitionNode;
use GraphQL\Language\AST\InputObjectTypeExtensionNode;
use GraphQL\Utils\Utils;
Expand All @@ -21,6 +22,7 @@
* isOneOf?: bool|null,
* fields: iterable<FieldConfig>|callable(): iterable<FieldConfig>,
* parseValue?: ParseValueFn|null,
* directives?: array<DirectiveNode>|null,
* astNode?: InputObjectTypeDefinitionNode|null,
* extensionASTNodes?: array<InputObjectTypeExtensionNode>|null
* }
Expand All @@ -46,14 +48,16 @@ class InputObjectType extends Type implements InputType, NullableType, NamedType
/** @var array<InputObjectTypeExtensionNode> */
public array $extensionASTNodes;

/** @var array<DirectiveNode> */
public array $directives;

/** @phpstan-var InputObjectConfig */
public array $config;

/**
* @phpstan-param InputObjectConfig $config
*
* @throws InvariantViolation
* @throws InvariantViolation
*/
public function __construct(array $config)
{
Expand All @@ -64,6 +68,7 @@ public function __construct(array $config)
$this->parseValue = $config['parseValue'] ?? null;
$this->astNode = $config['astNode'] ?? null;
$this->extensionASTNodes = $config['extensionASTNodes'] ?? [];
$this->directives = $config['directives'] ?? [];

$this->config = $config;
}
Expand Down
6 changes: 6 additions & 0 deletions src/Type/Definition/InterfaceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use GraphQL\Error\Error;
use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\InterfaceTypeDefinitionNode;
use GraphQL\Language\AST\InterfaceTypeExtensionNode;
use GraphQL\Utils\Utils;
Expand All @@ -21,6 +22,7 @@
* interfaces?: iterable<InterfaceTypeReference>|callable(): iterable<InterfaceTypeReference>,
* resolveType?: ResolveType|null,
* resolveValue?: ResolveValue|null,
* directives?: array<DirectiveNode>|null,
* astNode?: InterfaceTypeDefinitionNode|null,
* extensionASTNodes?: array<InterfaceTypeExtensionNode>|null
* }
Expand All @@ -36,6 +38,9 @@ class InterfaceType extends Type implements AbstractType, OutputType, CompositeT
/** @var array<InterfaceTypeExtensionNode> */
public array $extensionASTNodes;

/** @var array<DirectiveNode> */
public array $directives;

/** @phpstan-var InterfaceConfig */
public array $config;

Expand All @@ -50,6 +55,7 @@ public function __construct(array $config)
$this->description = $config['description'] ?? null;
$this->astNode = $config['astNode'] ?? null;
$this->extensionASTNodes = $config['extensionASTNodes'] ?? [];
$this->directives = $config['directives'] ?? [];

$this->config = $config;
}
Expand Down
6 changes: 6 additions & 0 deletions src/Type/Definition/ObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use GraphQL\Error\Error;
use GraphQL\Error\InvariantViolation;
use GraphQL\Executor\Executor;
use GraphQL\Language\AST\DirectiveNode;
use GraphQL\Language\AST\ObjectTypeDefinitionNode;
use GraphQL\Language\AST\ObjectTypeExtensionNode;
use GraphQL\Utils\Utils;
Expand Down Expand Up @@ -57,6 +58,7 @@
* fields: (callable(): iterable<mixed>)|iterable<mixed>,
* interfaces?: iterable<InterfaceTypeReference>|callable(): iterable<InterfaceTypeReference>,
* isTypeOf?: (callable(mixed $objectValue, mixed $context, ResolveInfo $resolveInfo): (bool|Deferred|null))|null,
* directives?: array<DirectiveNode>|null,
* astNode?: ObjectTypeDefinitionNode|null,
* extensionASTNodes?: array<ObjectTypeExtensionNode>|null
* }
Expand All @@ -72,6 +74,9 @@ class ObjectType extends Type implements OutputType, CompositeType, NullableType
/** @var array<ObjectTypeExtensionNode> */
public array $extensionASTNodes;

/** @var array<DirectiveNode> */
public array $directives;

/**
* @var callable|null
*
Expand Down Expand Up @@ -102,6 +107,7 @@ public function __construct(array $config)
$this->argsMapper = $config['argsMapper'] ?? null;
$this->astNode = $config['astNode'] ?? null;
$this->extensionASTNodes = $config['extensionASTNodes'] ?? [];
$this->directives = $config['directives'] ?? [];

$this->config = $config;
}
Expand Down
Loading
Loading