Skip to content

Commit b5d5e48

Browse files
committed
Sort schema printer methods
1 parent 10a2a4a commit b5d5e48

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

src/Utils/FederatedSchemaPrinter.php

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -100,28 +100,6 @@ public static function printType(Type $type, array $options = []): string
100100
return parent::printType($type, $options);
101101
}
102102

103-
/**
104-
* @param array<string, bool> $options
105-
*/
106-
protected static function printObject(ObjectType $type, array $options): string
107-
{
108-
if (empty($type->getFields())) {
109-
return '';
110-
}
111-
112-
$implementedInterfaces = static::printImplementedInterfaces($type);
113-
$extends = FederatedSchema::isReservedRootType($type->name) ? 'extend ' : '';
114-
115-
return static::printDescription($options, $type) .
116-
sprintf(
117-
"%stype %s%s {\n%s\n}",
118-
$extends,
119-
$type->name,
120-
$implementedInterfaces,
121-
static::printFields($options, $type)
122-
);
123-
}
124-
125103
/**
126104
* @param array<string, bool> $options
127105
*/
@@ -142,6 +120,27 @@ protected static function printEntityObject(EntityObjectType $type, array $optio
142120
);
143121
}
144122

123+
protected static function printFieldFederatedDirectives(FieldDefinition $field): string
124+
{
125+
$directives = [];
126+
127+
if (isset($field->config[EntityObjectType::FIELD_DIRECTIVE_IS_EXTERNAL])
128+
&& true === $field->config[EntityObjectType::FIELD_DIRECTIVE_IS_EXTERNAL]
129+
) {
130+
$directives[] = '@external';
131+
}
132+
133+
if (isset($field->config[EntityObjectType::FIELD_DIRECTIVE_PROVIDES])) {
134+
$directives[] = sprintf('@provides(fields: "%s")', static::printKeyFields($field->config[EntityObjectType::FIELD_DIRECTIVE_PROVIDES]));
135+
}
136+
137+
if (isset($field->config[EntityObjectType::FIELD_DIRECTIVE_REQUIRES])) {
138+
$directives[] = sprintf('@requires(fields: "%s")', static::printKeyFields($field->config[EntityObjectType::FIELD_DIRECTIVE_REQUIRES]));
139+
}
140+
141+
return implode(' ', $directives);
142+
}
143+
145144
/**
146145
* @param array<string, bool> $options
147146
* @param EntityObjectType|InterfaceType|ObjectType|TypeWithFields $type
@@ -178,27 +177,6 @@ static function (FieldDefinition $f, $i) use ($options) {
178177
);
179178
}
180179

181-
protected static function printFieldFederatedDirectives(FieldDefinition $field): string
182-
{
183-
$directives = [];
184-
185-
if (isset($field->config[EntityObjectType::FIELD_DIRECTIVE_IS_EXTERNAL])
186-
&& true === $field->config[EntityObjectType::FIELD_DIRECTIVE_IS_EXTERNAL]
187-
) {
188-
$directives[] = '@external';
189-
}
190-
191-
if (isset($field->config[EntityObjectType::FIELD_DIRECTIVE_PROVIDES])) {
192-
$directives[] = sprintf('@provides(fields: "%s")', static::printKeyFields($field->config[EntityObjectType::FIELD_DIRECTIVE_PROVIDES]));
193-
}
194-
195-
if (isset($field->config[EntityObjectType::FIELD_DIRECTIVE_REQUIRES])) {
196-
$directives[] = sprintf('@requires(fields: "%s")', static::printKeyFields($field->config[EntityObjectType::FIELD_DIRECTIVE_REQUIRES]));
197-
}
198-
199-
return implode(' ', $directives);
200-
}
201-
202180
protected static function printImplementedInterfaces(ObjectType $type): string
203181
{
204182
$interfaces = $type->getInterfaces();
@@ -240,4 +218,26 @@ protected static function printKeyFields($keyFields): string
240218

241219
return implode(' ', $parts);
242220
}
221+
222+
/**
223+
* @param array<string, bool> $options
224+
*/
225+
protected static function printObject(ObjectType $type, array $options): string
226+
{
227+
if (empty($type->getFields())) {
228+
return '';
229+
}
230+
231+
$implementedInterfaces = static::printImplementedInterfaces($type);
232+
$extends = FederatedSchema::isReservedRootType($type->name) ? 'extend ' : '';
233+
234+
return static::printDescription($options, $type) .
235+
sprintf(
236+
"%stype %s%s {\n%s\n}",
237+
$extends,
238+
$type->name,
239+
$implementedInterfaces,
240+
static::printFields($options, $type)
241+
);
242+
}
243243
}

0 commit comments

Comments
 (0)