Skip to content
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

[Improvement] Ability to override generated query/mutations names #586

Closed
Davide-Gheri opened this issue Oct 6, 2020 · 2 comments · Fixed by #601
Closed

[Improvement] Ability to override generated query/mutations names #586

Davide-Gheri opened this issue Oct 6, 2020 · 2 comments · Fixed by #601
Labels
enhancement New feature or request

Comments

@Davide-Gheri
Copy link

I understood that the names of Queries and Mutations generated from CRUDResolver (and all other subsets of Resolvers) comes from the DTO name and the "plural" version is generated using pluralize.

Thats ok for most of the cases, but sometimes plural is the same than singular (at least for pluralize), this causes the read one Query (findById) to be lost because it gets overridden by the read many Query (getMany).
I see that there is a dtoName options but it does not help me.

For example, I have an ObjectType defined as Agenda, where singular and plural are both agenda, to make the read one endpoint work I had to create a custom Resolver that extends ReadResolver and override both queryMany and findById methods, define both FindOneArgs and QueryArgs (because they are not exposed outside the Readable mixin) and call the getQueryManyHook and getFindOneHook to keep hooks working.
I also lost the "dynamic" queryMany return type based on pagingStrategy.

It would be awesome to have an option to override single endpoint names.

@doug-martin doug-martin added the enhancement New feature or request label Oct 9, 2020
@doug-martin
Copy link
Owner

@Davide-Gheri I'll take a look at this it shouldn't be too hard to add.

@doug-martin
Copy link
Owner

Hi @Davide-Gheri

I published a new version v0.21.1. The new version allows you to specify a one.name or many.name option to override the auto-generated endpoint name. Checkout the docs for an example.

Thank you for the feature request, and let me know if you have any issues!

-Doug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants