babyfish-ct / graphql-ts-client

Typescript DSL for GraphQL.
MIT License
147 stars 20 forks source link

Enums not properly encoded in query #24

Closed VojtaStanek closed 2 years ago

VojtaStanek commented 2 years ago

I have the following fetcher (where publishAt is an enum):

export const articleFetcher = article$
    .issues(
        {
            limit: 1,
            orderBy: [{ article: { publishAt: "desc" } }],
        },
        issueArticle$.id
    )

It results in following query:

query {
    listArticle {
        issues(
            limit: 1,
            orderBy: [{article: {publishAt: "desc"}}]
        ) {
            issue {
                legacyId
            }
        }
    }
}

instead of

query {
    listArticle {
        issues(
            limit: 1,
            orderBy: [{article: {publishAt: desc}}]
        ) {
            issue {
                legacyId
            }
        }
    }
}
babyfish-ct commented 2 years ago

Can you paste the schema definition of issue(limit, orderBy)?

VojtaStanek commented 2 years ago

Schema in example here is similar: https://docs.contember.com/reference/engine/content/queries

This one looks something like this:

type Article {
    issues(
        filter: IssueArticleWhere
        orderBy: [IssueArticleOrderBy!]
        offset: Int
        limit: Int
    ) : [IssueArticle!]!
}

input IssueArticleWhere {
    # ...
}

input IssueArticleOrderBy {
    article: ArticleOrderBy
}

input ArticleOrderBy {
    publishAt: OrderDirection
}

enum OrderDirection { asc, desc }

type IssueArticle {
    # ...
}
babyfish-ct commented 2 years ago

Dose EnumInputMetadata contain IssuceArticleOrderBy, ArticleOrderBy?

Can you paste them?

babyfish-ct commented 2 years ago

Neednot, I reproduced it.

babyfish-ct commented 2 years ago

DONE, please use 3.1.14

VojtaStanek commented 2 years ago

Thanks, works like a charm!