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
              
            -
| Hello! We are currently using Graphql Kotlin (thanks for this, btw) to develop a replacement server for Hasura. Currently Hasura uses the snake_case database column names in it's responses. We were wondering if it is possible to tell the schema generate to do this conversion for us, since our field names are camelCase in the code. If not it's not a big deal since we can use  Thanks | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            smyrick
          
      
      
        Jun 4, 2021 
      
    
    Replies: 1 comment 3 replies
-
| 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
  }
} | 
Beta Was this translation helpful? Give feedback.
                  
                    3 replies
                  
                
            
      Answer selected by
        keith-miller
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
You could accomplish this with the schema generator hooks: