edgedb / edgedb-js

The official TypeScript/JS client library and query builder for EdgeDB
https://edgedb.com
Apache License 2.0
511 stars 65 forks source link

Custom naming strategy #975

Open hnordt opened 5 months ago

hnordt commented 5 months ago

The whole JS ecosystem has the camel case convention for property names.

It would be nice if this JS client supports the same naming strategy feature from the DotNet client https://docs.edgedb.com/libraries/dotnet/customtypes#using-a-naming-strategy, so the property names in query results could be camel case enforced.

CarsonF commented 5 months ago

Why not name your schema in camel case? that's what I do.

hnordt commented 5 months ago

Why not name your schema in camel case? that's what I do.

It feels a bit inconsistent, because both the SDL and EdgeQL use snake case for everything.

CarsonF commented 5 months ago

IMO that's the lesser evil, than trying to have naming translation for a specific client. In practice we have very little snake case; pretty much just the builtin functions.

hnordt commented 5 months ago

I agree that a naming translation is bad, but it would be nice if we can do like Drizzle where you can "alias" the property name:

{ myAge: integer('my_age') }

The SDL could support something like:

type Movie {
  required title: str;
  release_year as releaseYear: int64;
}

That way I can follow the naming conventions of EdgeQL and match the naming conventions of TypeScript.