-
Notifications
You must be signed in to change notification settings - Fork 106
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
possible-type-extension
erroring when extending types defined in separate files.
#787
Comments
Thank you for the reproduction repo 🙂, it looks like this is a similar problem to this issue. I will look in detail to find a solution after the major v3 version will be released. |
@JustinTRoss Fixed in |
Good work 💪 . That appears to have mostly solved it. Parsing errors throw it for a loop though. That issue extends more broadly than this rule in some circumstances, but some seem specific to this rule. Broadly, a parsing error in one file seems to throw a parsing error in all files. I can open another issue for this if it doesn't already exist. Specific to this rule, if I put a parsing error in one file, I get an erroneous Repro repo updated with example. In case it isn't obvious, here is parsing error, and here is where erroneous 'possible-type-extension' error triggers. |
Thanks @JustinTRoss, I’ll took a look and fix it ;) |
You're quick! I notice it happens in other scenarios as well. If you make a second valid extension in another file, you get the error. See this branch for details. |
@JustinTRoss Both errors were fixed in |
You're quick! Those two scenarios look mitigated. I come bearing another 🙌 . 😛 If you define a duplicate version of the same type with violations in it, like duplicate conflicting fields, depending the order of loaded files, it will report either as an error merging types or an error defining type. At the same time, it errors out and inaccurately conveys that the eslint Try running |
Possibly getting away from the scope of this rule and the changes made here, but I found I could invalidly define a union and extend it without any issue. See this branch for details. Further, if I defined union in certain invalid ways, it errors regarding merging of unrelated valid types in a different file. See this branch for details. |
this is expected behavior, we can't build a schema that contains validation errors like duplicated fields, in this case, we aren't able to provide a GraphQL schema for rules that require it.
Fixed in /Users/dimitri/Desktop/graphql-eslint-issue-repro/src/index.ts
5:1 error Union type Product can only include Object types, it cannot include Genre @graphql-eslint/possible-type-extension
/Users/dimitri/Desktop/graphql-eslint-issue-repro/src/modules/Schema/first/firstSchema.ts
3:1 error Union type Product can only include Object types, it cannot include Genre @graphql-eslint/possible-type-extension
/Users/dimitri/Desktop/graphql-eslint-issue-repro/src/modules/Schema/second/secondSchema.ts
3:1 error Union type Product can only include Object types, it cannot include Genre @graphql-eslint/possible-type-extension
✖ 3 problems (3 errors, 0 warnings)
It's related to how |
Fixed in |
Thanks for the improvements. I'll upgrade to 3.4.
That makes sense. It was surprising that it conveyed to the user that they had not provided a |
Describe the bug
possible-type-extension
erroring when extending types defined in separate files.Error:
Additionally, if this error triggers for any file, an error shows up in lint results for every file in which a type was extended. Also, I notice messaging is slightly different when extending known types like
Query
vs custom types likeNotQuery
.To Reproduce
Steps to reproduce the behavior:
Run
yarn lint
in below repo.https://github.com/JustinTRoss/graphql-eslint-issue-repro
Expected behavior
Ideally, no errors would be thrown when extending a type defined in another file.
Environment:
@graphql-eslint/...
: 2.5Additional context
The text was updated successfully, but these errors were encountered: