babyfish-ct / graphql-ts-client

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

Allow custom scalar types #16

Closed VojtaStanek closed 2 years ago

VojtaStanek commented 2 years ago

I would like to specify custom types such as 1 | 2 | 3, unknown, string | undefined.

fixes #1

VojtaStanek commented 2 years ago

Thanks a lot!

babyfish-ct commented 2 years ago

3.1.0

Custom inline type

{
    "scalarTypeMap": { 
        "GraphQLPoint": "{readonly x: number, readonly: number}" 
                // Be careful, this value is string
    }
}

Custom non-inline type

{
    "scalarTypeMap": { 
        "GraphQLPoint": {
            typeName: "Point",
            importSource: "commons/Type"
                    // "import { Point } from '../common/Types';" will be generated
        }
    }
}