@ref smart tag applies inflector to query name
Context
(v5)
Consider the case where I have tables:
-
app.users{id} -
app.invoices{id,user_id} -
app.transactions{id,invoice_id}
I want a graphql query that gets all transactions for a user:
userById(id: "") {
transactionsByUserId { ... }
}
I could denormalize user_id into the transactions table. But if I don't want to do that, I can use the ref smart tag to tell postgraphile how to join transactions through invoices.
export const SmartTagsPlugin = makeJSONPgSmartTagsPlugin({
version: 1,
config: {
class: {
"app.users": {
tags: {
ref: "transactions via:(id)->invoices(user_id);(id)->transactions(invoice_id) plural",
},
},
},
},
});
That works, and it generates:
userById(id: "") {
transactions { ... }
}
(Which is probably good for everyone using the simplify-inflections plugin)
But in my case, I want the query to be transactionsByUserId since
- I'm using vanilla v5 and that's what postgraphile would generate if I added
user_idcolumn to the transactions table. - That's already the naming convention of the rest of my API.
Problem
If I try to use another name for the ref tag: transactionByUserId via:(id)->invoices(user_id);(id)->transactions(invoice_id) plural, then it generates this:
userById(id: "") {
transactionsByUserIds { ... } # <-- notice the trailing 's'
}
This is my concrete use case, but of course this limitation applies to anyone who has any reason to name the query with a suffix that shouldn't be pluralized.
This might be a good place to ask if we want inflectors applied at all to the ref.