type->fields()) ->filter(fn (Field $field) => $field instanceof SortableField) ->map(fn (Field $field) => [SortDirection::resolveForAsc($field), SortDirection::resolveForDesc($field)]) ->flatten() ->implode(PHP_EOL); } /** * Resolve the SortableColumns as a GraphQL string representation. */ public function __toString(): string { $enumCases = $this->resolveEnumCases(); if (blank($enumCases) || (method_exists($this->type, 'sortable') && ! $this->type->{'sortable'}())) { return ''; } return sprintf( 'enum %sSortableColumns { %s }', $this->type->getName(), $enumCases, ); } }