babyfish-ct / graphql-ts-client

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

Invalid ts generated (double readonly) #17

Closed VojtaStanek closed 2 years ago

VojtaStanek commented 2 years ago

Codegen generates following code


    paths<
        X extends object, 
        XVariables extends object
    >(
        child: ObjectFetcher<'_PathFragment', X, XVariables>
    ): _MutationErrorFetcher<
        T & {readonly "paths": readonly readonly X[][]}, 
        TVariables & XVariables
    >;

    paths<
        X extends object, 
        XVariables extends object, 
        XAlias extends string = "paths", 
        XDirectives extends { readonly [key: string]: DirectiveArgs } = {}, 
        XDirectiveVariables extends object = {}
    >(
        child: ObjectFetcher<'_PathFragment', X, XVariables>, 
        optionsConfigurer: (
            options: FieldOptions<"paths", {}, {}>
        ) => FieldOptions<XAlias, XDirectives, XDirectiveVariables>
    ): _MutationErrorFetcher<
        T & (
            XDirectives extends { readonly include: any } | { readonly skip: any } ? 
                {readonly [key in XAlias]?: readonly readonly X[][]} : 
                {readonly [key in XAlias]: readonly readonly X[][]}
        ), 
        TVariables & XVariables & XDirectiveVariables
    >;

readonly readonly X[][] is not valid typescript - it should be readonly (readonly X[])[] instead.

The GraphQL schema looks like this:

type _MutationError {
  paths: [[_PathFragment!]!]!
}
VojtaStanek commented 2 years ago

This is fixed in 3.1.2, thanks.

babyfish-ct commented 2 years ago

Not 3.1.2 because it is submitted 3.1.3 and 3.1.4 several minutes ago