Zaid-Ajaj / Snowflaqe

A dotnet CLI to generate type-safe GraphQL clients for F# and Fable with automatic deserialization, static query verification and type checking
MIT License
157 stars 26 forks source link

Control over GraphqlClient type name? #3

Closed njlr closed 4 years ago

njlr commented 4 years ago

Suppose I have a config like this:

{
  "schema": "./introspection.json",
  "queries": "./queries",
  "project": "My.GraphQL.Project",
  "output": "./graphql",
  "target": "fable"
}

Then my generated project will have a type like this:

namespace My.GraphQL.Project

// ...

type My.GraphQL.ProjectGraphqlClient(url: string, headers: Header list) =
    new(url: string) = My.GraphQL.ProjectGraphqlClient(url, [ ])

    member _.LatestEntities() =
        async {

// ...

The namespace is what I expected but the type name of the client is a bit cumbersome.

Is there a way to control the type name of the client?

For example:

namespace My.GraphQL.Project

// ...

type GraphqlClient(url: string, headers: Header list) =
    new(url: string) = My.GraphQL.ProjectGraphqlClient(url, [ ])

    member _.LatestEntities() =
        async {

// ...
Zaid-Ajaj commented 4 years ago

Is there a way to control the type name of the client?

Right now there isn't a way but I accept PRs regarding these things :smile:

Maybe we can add a overrideClientName attribute of type string which will do just than or simply remove the project prefix from the GraphqlClient type (i.e. adding a config removeProjectPrefix of type bool)

njlr commented 4 years ago

PR: https://github.com/Zaid-Ajaj/Snowflaqe/pull/4

Zaid-Ajaj commented 4 years ago

Added and published as of v1.4 :rocket: