json-schema-to-graphql-types icon indicating copy to clipboard operation
json-schema-to-graphql-types copied to clipboard

Incorrect names generated

Open avdv opened this issue 6 years ago • 1 comments

Input:

{
  ...
  "content": {
     "properties": {
         "content-categories": {
              "$ref": "#/definitions/content-categories"
         }
     }
  }
}

Output:

type SampleContent {
  content-categories: DefinitionContentCategories
}

The name of the field is invalid, according to https://spec.graphql.org/June2018/#Name

Name /[_A-Za-z][_0-9A-Za-z]*/

AFAICS, dashes are already converted to underscores for enum values. Probably the same should be done for field names. Or maybe make it configurable whether to use camel-case or lower-cased underscores or something else.

avdv avatar Feb 04 '20 08:02 avdv

Nice catch! Any chance your usecase is motivating enough to contribute a fix for that? I'm happy to review and merge quickly.

mdlavin avatar Feb 04 '20 13:02 mdlavin