Skip to content

Debug auto-derived implementation doesn't display queries correctly #518

Open
@edmondop

Description

@edmondop

If you have a query saved in a graphql file on disk, it is likely to be correctly formatted and contain newlines

            pub struct RepositoryWithPullRequests;
            pub mod repository_with_pull_requests {
                #![allow(dead_code)]
                use std::result::Result;
                pub const OPERATION_NAME: &str = "RepositoryWithPullRequests";
                pub const QUERY: &str = "query RepositoryWithPullRequests(\n  $repositoryName: String!\n  $repositoryOwner: String!\n  $count: Int!\n  $pullRequestStates: [PullRequestState!]!\n) {\n  repository(name: $repositoryName, owner: $repositoryOwner) {\n    owner {\n      __typename\n      login\n    }\n    name\n    defaultBranchRef {\n      name\n    }\n    pullRequests(first: $count, states: $pullRequestStates) {\n      pageInfo {\n        hasNextPage\n        endCursor\n      }\n\n      totalCount\n      nodes {\n        author {\n          __typename\n          login\n        }\n        id\n        url\n        title\n        state\n        createdAt\n        updatedAt\n        closedAt\n        ## uh-oh not very safe but it's ok\n        labels(first: 100) {\n          edges {\n            node {\n              id\n              name\n            }\n          }\n        }\n      }\n    }\n  }\n}\n";
                const __QUERY_WORKAROUND: &str = "query RepositoryWithPullRequests(\n  $repositoryName: String!\n  $repositoryOwner: String!\n  $count: Int!\n  $pullRequestStates: [PullRequestState!]!\n) {\n  repository(name: $repositoryName, owner: $repositoryOwner) {\n    owner {\n      __typename\n      login\n    }\n    name\n    defaultBranchRef {\n      name\n    }\n    pullRequests(first: $count, states: $pullRequestStates) {\n      pageInfo {\n        hasNextPage\n        endCursor\n      }\n\n      totalCount\n      nodes {\n        author {\n          __typename\n          login\n        }\n        id\n        url\n        title\n        state\n        createdAt\n        updatedAt\n        closedAt\n        ## uh-oh not very safe but it\'s ok\n        labels(first: 100) {\n          edges {\n            node {\n              id\n              name\n            }\n          }\n        }\n      }\n    }\n  }\n}\n";

the problem with this is that the Debug macro auto-derive will escape newline, using the Debug format unusable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions