Vincit / objection-graphql

GraphQL schema generator for objection.js
MIT License
307 stars 34 forks source link

$formatDatabaseJson doesn't work for a newer versions of this library #17

Closed nasushkov closed 7 years ago

nasushkov commented 7 years ago

Hi I'm trying to upgrade from version 0.1.2. I use _snakecase for db objects naming and camelCase for my ORM models. I use the following code to parse from one format to another:

  $formatDatabaseJson(json) {
        json = super.$formatDatabaseJson(json)
        return mapKeys(json, (value, key) => snakeCase(key))
    }
    $parseDatabaseJson(json) {
        json = mapKeys(json, (value, key) => camelCase(key))
        return super.$parseDatabaseJson(json)
    }

My queries used to work for version 0.1.2, but now they fail and I think the reason is wrong parsing behavior as I've got wrong queries in my log:

select "area_param"."paramName", "area_param"."type", "area_param"."displayUnit", "area_param"."displayName" from "area_param"

koskimas commented 7 years ago

Thanks for reporting this. I'll check out what is going on.

koskimas commented 7 years ago

Could you put this in your package.json

"objection": "git://github.com/Vincit/objection-graphql.git#382d2ed"

and test if it fixed you bug?

nasushkov commented 7 years ago

@koskimas Thanks! I'll try it

nasushkov commented 7 years ago

@koskimas it works!

koskimas commented 7 years ago

Great! I'll write couple of test cases to prevent this from happening again and I'll publish a patch after that.

koskimas commented 7 years ago

Fixed in v0.2.3