apollo-tooling icon indicating copy to clipboard operation
apollo-tooling copied to clipboard

Add an option to remove underscores from generated interfaces.

Open pietmichal opened this issue 6 years ago • 5 comments

Codegen generates interfaces with underscores.

For example: myQuery_foo_bar.

This default behaviour causes problems when using ESLint camelcase rule -https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/camelcase.md.

Importing these interfaces triggers a linting error.

I'd suggest adding --no-underscores flag that would cause interfaces to be generated without underscores. For example: myQueryFooBar.

pietmichal avatar Jul 18 '19 13:07 pietmichal

Consider using this: https://graphql-code-generator.com/

pietmichal avatar Oct 02 '19 12:10 pietmichal

Hi, I got the same issue here... it's a tiny detail but it's actually pretty annoying.

Seems odd to me to add so much tooling when the main feature is already available for such an option.

Are you open for PR? At least for typescript codegen?

adriengibrat avatar Apr 22 '20 07:04 adriengibrat

We have the same issue. I much prefer the output from apollo-codegen than from graphql-code-generator as it is easier to use query results in nested react components but the underscores break linting and style requirements for our project.

Would be great if there was an option to use camelCase instead of underscores.

anark avatar May 13 '20 03:05 anark

Having the ability to pick a "namingConvention" such as: Underscores (aka snake_case), camelCase, PascalCase, kebab-case and any other common variation I may have missed, would be ideal.

e.g:

// apollo.config.js
module.exports = {
  client: {
    service: {
      name: "My Client",
      namingConvention: "camel", // default: "snake" optional: "camel" "pascal" "kebab" etc.
    },
  },
};

or

 apollo client:codegen --target typescript --namingConvention camel

haysclark avatar Oct 28 '20 21:10 haysclark

Any plans for this issue? Would be great to have.

paltman avatar Oct 01 '21 15:10 paltman