-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get singular and plural model names from jsonSchema #61
base: master
Are you sure you want to change the base?
Conversation
This is similar to `listFieldName` and `fieldName` from `graphQLBuilder().model()`'s extra parameter. It can simple replace `listFieldName` and `fieldName` if you can add `collectiveName` and `singleName` to your models's jsonSchema. The benefit is: * Center the model description; * Produce the correct single type name in the result graphQL schema; * Share the model identification with oder modules in the app.
I ran into a problem when the name of the table is "users" and I have to write userss (double s) i think this is a useful PR. |
Any thought on when this will be merged? I've run in to this issue now as well. |
Please merge 🙏 |
@sbabushkin could you check this PR please? :) |
const listFieldName = modelData.opt.listFieldName || (`${defaultFieldName}s`); | ||
const schema = modelData.modelClass.jsonSchema; | ||
const singleFieldName = schema.singleName || modelData.opt.fieldName || defaultFieldName; | ||
const listFieldName = schema.collectiveName || modelData.opt.listFieldName || (`${defaultFieldName}s`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const listFieldName = schema.collectiveName || modelData.opt.listFieldName || (`${defaultFieldName}s`); | |
const listFieldName = schema.collectiveName || modelData.opt.listFieldName || (`${singleFieldName}s`); |
Bump! I've encountered this in my project as well. Would be great to get this merged in :) |
This is similar to
listFieldName
andfieldName
fromgraphQLBuilder().model()
's extra parameter.It can simple replace
listFieldName
andfieldName
if you can addcollectiveName
andsingleName
to your models's jsonSchema.The benefit is: