Skip to content

Is it possible to auto convert camelCase to snake_case when using the schema generator? #1175

Answered by smyrick
keith-miller asked this question in Q&A
Discussion options

You must be logged in to vote

You could accomplish this with the schema generator hooks:

class MyHooks : SchemaGeneratorHooks {
  fun willAddGraphQLTypeToSchema(type: KType, generatedType: GraphQLType): GraphQLType  {
    if (generatedType is GraphQLNamedType  && isSnakeCase(generatedType.name)) {
      // rebuild the type with new name here
    }

    return generatedType
  }
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@keith-miller
Comment options

@keith-miller
Comment options

@smyrick
Comment options

Answer selected by keith-miller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants