Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline documentation with a graphql schema leads to unnececairy indent/code block formatting #1167

Open
mousetail opened this issue Mar 18, 2024 · 1 comment
Assignees

Comments

@mousetail
Copy link

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Version/Branch 1.2.0

I have a schema like this:

"""
A date time in RFC3339-Extended format.

Eg. 2023-03-02T14:12:12.1222Z
"""
scalar DateTime

However, it renders like this:

afbeelding

In the JSON schema:

"A date time in RFC3339-Extended format.\n            \n            Eg. 2023-03-02T14:12:12.1222Z"

It seems to be inserting unnecessary spaces after every line break.

Some more debug info

The generated class seems to have indented the string:

<?php
/**
 * THIS FILE WAS GENERATED AND SHOULD NOT BE EDITED MANUALLY.
 */
final class DateTimeType extends CustomScalarType implements GeneratedTypeInterface, AliasedInterface
{
    public const NAME = 'DateTime';
    
    public function __construct(ConfigProcessor $configProcessor, GraphQLServices $services)
    {
        $config = [
            'name' => self::NAME,
            'description' => 'A date time in RFC3339-Extended format.
            
            Eg. 2023-03-02T14:12:12.1222Z',
            'serialize' => fn() => CustomScalarNode::mustOverrideConfig(...\func_get_args()),
            'parseValue' => fn() => CustomScalarNode::mustOverrideConfig(...\func_get_args()),
            'parseLiteral' => fn() => CustomScalarNode::mustOverrideConfig(...\func_get_args()),
        ];

Using a double quoted string with escapes instead of actual newlines might be better, or wrapping it in a function that can properly remove the indentation.

@Vincz Vincz self-assigned this Mar 30, 2024
@Vincz
Copy link
Collaborator

Vincz commented Mar 30, 2024

The generation is made by https://github.com/murtukov/php-code-generator.git
It should be handled there. @mousetail can you re-open the issue here describing the need to have multilines string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants