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

Two GraphQL queries are being created with the same name #525

Open
malvfr opened this issue Nov 18, 2020 · 2 comments
Open

Two GraphQL queries are being created with the same name #525

malvfr opened this issue Nov 18, 2020 · 2 comments

Comments

@malvfr
Copy link

malvfr commented Nov 18, 2020

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

The findAll and findOne boilerplate queries are being created with the same name, resulting in only the latter being generated on the GQL Schema file.

image

I've tracked the problem in the files and seems to me that the faulty code is in this file: "src/lib/resource/files/ts/name.resolver.ts" . If just altering the name of the query suffice, I could send a PR.

Expected behavior

The two resolvers should be generated into the GQL Schema file.

Minimal reproduction of the problem with instructions

run the nest g resource and select the GraphQL Code First approach**. Then, look at the generated GQL file.

What is the motivation / use case for changing the behavior?

Fix the bug

Environment


Nest version: 7.5.1

 
For Tooling issues:
- Node version: 14.15.0  
- Platform: Linux on WSL2 

@kamilmysliwiec
Copy link
Member

The solution to this issue isn't that obvious. The reason why queries are generated with the same name in your example is that pluralize package gives the exact same word for both singular and plural forms of "portfolio" (which is correct). This should not happen for most of the existing nouns.

Anyways, we should add an additional protection mechanism to prevent such names clash. If you have any ideas + you would like to create a PR for this issue, that would be more than welcome!

@bmeverett
Copy link

HI, I also ran into this issue when creating a new resource.

To solve this, I would think for findAll it should always be pluralized since you're returning multiple. Then the findOne can be singularized.

So going with the example of this issue, Portfolio, findAll would be Portfolios and findOne would be Portfolio. If the resource was already named Portfolios it seems pluralize just returns the string and doesn't double pluralize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants