dosco / graphjin

GraphJin - Build NodeJS / GO APIs in 5 minutes not weeks
https://graphjin.com
Apache License 2.0
2.91k stars 179 forks source link

Support for Camel Case #231

Closed dosco closed 3 years ago

dosco commented 3 years ago

Hello,

Is there any support or thoughts to having the ability to take in a query with camel case fields, translate to snake case for the db and then output in camel case?

Or are there any settings for this?

The reason I ask is that my preference is snake case in the db, but camel case in API interaction and wanted to get your thoughts.

Originally posted by @twhit-mrwebapps in https://github.com/dosco/graphjin/discussions/228

dosco commented 3 years ago

I'll take a look later today

magicMustard commented 3 years ago

Very excited, thank you

magicMustard commented 3 years ago

Hi Dosco,

I downloaded you're new version and I think I've discovered a possible bug.

I have 2 db tables, states & countries

query { states { id, country { phoneCode, countryCode } } }

DB Tables:

CREATE TABLE countries ( id CHARACTER(26) NOT NULL, country_code VARCHAR(5) NOT NULL, country VARCHAR(100) NOT NULL, phone_code INT DEFAULT 0, has_postcode BOOLEAN DEFAULT false, sort_order INT DEFAULT 0, PRIMARY KEY (id) )

CREATE TABLE states ( id CHARACTER(26) NOT NULL, state VARCHAR(100) NOT NULL, country_id CHARACTER(26) DEFAULT NULL, timezone_id CHARACTER(26) DEFAULT NULL, PRIMARY KEY (id) )

I get the following error: 2021/05/23 18:10:04 column: 'countries.y_code' not found

I also get the same error when calling countries by itself

query { countries { phoneCode, countryCode } }

I suspect it may be attempting to translate the "countryCode" of a field incorrectly.

dosco commented 3 years ago

Good catch I know whats causing that bug its the count part of countryCode

dosco commented 3 years ago

fixed!