dotansimha / graphql-code-generator

A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
https://the-guild.dev/graphql/codegen/
MIT License
10.85k stars 1.33k forks source link

Minor naming inconsistency #3080

Open tobias-kuendig opened 4 years ago

tobias-kuendig commented 4 years ago

Given the following query:

query tree($parent: Int!) {
    systemTree(parent: $parent) {
        ...fields
    }
}

using this config:

overwrite: true
schema: "schema/*.graphql*"
documents: "*.gql"
config:
    declarationKind: 'interface'
generates:
    src/common/graphql/types.d.ts:
        config:
            preResolveTypes: true
        plugins:
        - "typescript"
        - "typescript-operations"

The following types are generated:

export type TreeQuery = { /* ... */ }

export type TreeQueryVariables = {
  parent: Scalars['Int']
};

export interface QuerySystemTreeArgs {
  parent: Scalars['Int']
}

It seems like the query uses a postfix TreeQuery where the arguments use a prefix QuerySystemTreeArgs.

It would be nice if this naming schema was the same both times:

TreeQuery
TreeQueryVariables
SystemTreeQueryArgs

Is this configurable?

dotansimha commented 4 years ago

@tobias-kuendig you are right, it was an issue before, and it's customizable at the moment, mostly because other plugins might use those types.

We are not changing it because it will cause a breaking change for all current users.

Keeping open, maybe in the future we'll fix it / allow to customize