Prisma1: Configure plural names of models

Created on 14 Dec 2016  路  12Comments  路  Source: prisma/prisma1

In some cases it might be needed to provide a custom plural name of a model.

Here is how it could be configured in the datamodel:

type Person @plural(name: "People") {
  name: String!
}
kinfeature aredatamodel areschema-generation

Most helpful comment

Hello, I'll add that it needs fixing, "Todo" becomes "Todoes" :).

All 12 comments

Hello, I'll add that it needs fixing, "Todo" becomes "Todoes" :).

This is also important for localized model names

We're using GraphCMS which uses Prisma and this looks really bad in the interface. "WhatWeDoes", "HomepageIntroes" etc.

I ran into this today with a model Person that generates the query persons, but I would prefer people.

Is there a third party inflection library being used?

I ran into this today - model Todo that generates todoes :)

TBH I don't see why an external pluralisation library isn't being used. No doubt these problems have been solved countless times already. https://yarnpkg.com/en/package/pluralize, for example, with 17.8m downloads in the last 30 days:

pluralize('Todo') // Todos
pluralize('Person') // People
pluralize('WhatWeDo') // WhatWeDos
pluralize('HomepageIntro') // HomepageIntros

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

Same problem here.

Postgraphile is a nice reference on how to solve this issue.

Has this been solved? If not, which library or mechanism is being used by prisma to pluralize?

Any updates?

They know the issue and acknowledge most of the code in the wild is untested. Amending this issue would render a breaking change.

What I would recommend is having your own set of model names overwriting the ones Prisma creates.

Hey people, any updates on this?

Was this page helpful?
0 / 5 - 0 ratings