wundergraph / graphql-go-tools

GraphQL Router / API Gateway framework written in Golang, focussing on correctness, extensibility, and high-performance. Supports Federation v1 & v2, Subscriptions & more.
https://graphql-api-gateway.com
MIT License
704 stars 133 forks source link

astprinter doesn't print indentation within multi line strings properly #105

Closed jensneuse closed 1 year ago

jensneuse commented 5 years ago

The astprinter seems to ignore indentation within multi line strings (descriptions). E.g. when there's an example GraphQL query with proper indentation within the description the printer falls short printing the indentation properly.

jensneuse commented 5 years ago

Example input:

"PARAMETER_SOURCE defines the source of a dyanmic parameter"
enum PARAMETER_SOURCE {
    "parameter from the context object which could be pupulated by the http wrapper"
    CONTEXT_VARIABLE
    """
    parameter from the parent object
    example:
    consider the following query:
    {
        user(id: 1) {
            userID
            friends
        }
    }
    Using the PARAMETER_SOURCE 'OBJECT_VARIABLE_ARGUMENT' with sourceName 'userID' returns the userID for user with id 1 at runtime.
    This way you can dynamically build a query to the friends ressource using the userID at runtime and inject it into the second query.
    """
    OBJECT_VARIABLE_ARGUMENT
    """
    parameter from the field arguments
    example:
    consider the following query:
    {
        user(id: 1) {
            friends
        }
    }
    Using the PARAMETER_SOURCE 'FIELD_ARGUMENTS' with sourceName 'id' returns 1 at runtime.
    This way you can render the ressource url for /user/:id to /user/1 at runtime dynamically.
    """
    FIELD_ARGUMENTS
}

When parsing and printing the query the indentation for the two example queries get lost.