Closed peay closed 6 years ago
If you simply mean renaming the tables you can do so using the v4 inflector. It's not "official" yet and may undergo breaking changes before the final v4 release, but it should be enough to scratch your itch.
https://github.com/postgraphql/postgraphql/pull/506#issuecomment-328831456
This looks pretty great, thanks, will give it a try!
Do you already have a timeline in mind for when this could graduate into an official release?
Not at the moment, sorry :(
Very soon 🙊
You can provide custom inflectors quite easily in v4; e.g. if you wanted to change the patch input to update mutation from *Patch
to *ChangeSet
you could create a plugin like this:
MyInflectorPlugin.js:
const { makeAddInflectorsPlugin } = require('graphile-utils');
module.exports = makeAddInflectorsPlugin({
patchType(typeName: string) {
// return this.upperCamelCase(`${typeName}-patch`);
return this.upperCamelCase(`${typeName}-change-set`);
},
});
Then --append-plugins `pwd`/MyInflectorPlugin.js
The built in inflectors are defined in PgBasicsPlugin; you can overwrite any that you want. Be sure to not use arrow functions otherwise you'll override this
and lose access to the other inflectors.
To roll out schema changes, I am experimenting with deploying a new version of certain tables (say, with a
_v2
suffix) and testing a bit the API before making it available.To this end, I've been looking for a way to "alias" table names: being able to refer in queries to
objectName
, and have some internal mapping in PostgraphQL that says whetherobjectName
is tableobject_name_v1
orobject_name_v2
.The obvious candidate is to use views, but since this does not support foreign key references yet, this is a bit limited (see #376). Another way is to move this "mapping" to the clients querying the PostgraphQL API, but this also isn't very satisfactory, especially with a lot of different client types.
Given the limitations with using views, I would find some kind of aliasing feature for table names very useful.