-
Hey there! I'm trying to figure out how to declare a Directive and the value of its argument in an ObjectType definition. For example, if I have the following defined Directive: new Directive([
'name' => 'DIRECTIVE_NAME',
'locations' => [
DirectiveLocation::OBJECT,
],
'args' => [
'DIRECTIVE_ARGUMENT_NAME' => [
'type' => Type::nonNull(new EnumType([
'name' => 'ENUMERATION_TYPE_NAME',
'values' => [
'DIRECTIVE_ARGUMENT_VALUE_1',
'DIRECTIVE_ARGUMENT_VALUE_2',
],
])),
]
]
]) How can I declare that Directive on an ObjectType and pick a value for DIRECTIVE_ARGUMENT_NAME for that ObjectType? I've tried a few things including writing an SDL document type OBJECT_TYPE_NAME @DIRECTIVE_NAME(DIRECTIVE_ARGUMENT_NAME: DIRECTIVE_ARGUMENT_VALUE_1) {
FIELD_NAME: String
} and then parsed it using I've tried the following, trying to replicate the AST structure and taking inspiration from the new ObjectType([
'name' => 'OBJECT_TYPE_NAME',
'interfaces' => static function () {
return [new InterfaceType([
'name' => 'INTERFACE_NAME',
'fields' => static function (): array {
return [
'FIELD_NAME' => Type::string(),
];
},
]];
},
'directives' => [
[
new DirectiveNode([
'name' => new NameNode(['value' => 'DIRECTIVE_NAME']),
'arguments' => new NodeList(
[
new ArgumentNode([
'value' => new EnumValueNode(['value' => 'DIRECTIVE_ARGUMENT_VALUE_1']),
'name' => new NameNode(['kind' => 'Name', 'value' => 'DIRECTIVE_ARGUMENT_NAME'])
]),
]
),
]),
],
],
]) Any hints or help would be greatly appreciated! Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This has been discussed in #588 (comment) |
Beta Was this translation helpful? Give feedback.
This has been discussed in #588 (comment)