-
-
Notifications
You must be signed in to change notification settings - Fork 675
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
1.0.0-rc.2 Schema updated, but resolver not called #662
Comments
Zip file pasted on code hosting repository 😅 2020 is a crazy year
TypeGraphQL 1.0 has a proper schema isolation, so maybe you forgot to register some resolver or reference some type in the other module. Maybe this can guide you to find the root cause: If the repro zip is minimal enough, I will take a look, but I would prefer really small, clean and 3rd party deps free repo 😉 |
@MichalLytek it's a couple hundred LOC. If you prefer a git repo over zip, here you go: https://github.com/kingsmendv/typegraphql-issue-662 |
The bug was in But now the If you can't provide my a clean, |
I've created an example for GraphQL Modules and everything works fine: Maybe you need to try to play with |
Thanks @MichalLytek! Looks like orphanedTypes did the trick. I was trying to find more information on the "schema isolation breaking change" and wasn't able to intuit what changed and that the orphanedTypes option was required. For anyone else who's curious in the future, the fix ultimately led me to this documentation: https://typegraphql.com/docs/bootstrap.html#create-executable-schema |
In case of my example, it's about adding a field via the I am going to fix that issue so the usage with GraphQL Modules and similar cases will be less problematic. |
Describe the Bug
Before I get into it... please forgive me for only knowing how to describe this bug in the context of graphql modules. While the repro is inside the context of graphql modules, I believe the bug is in type-graphql, as 0.17.6 works fine, but 1.0.0-rc.2 leads to an issue. However, the bug might be in graphql itself, not in type-graphql.
The main benefit of Graphql modules is that the library allows defining separate "modules", each with their own schemas and resolvers, and essentially compiles them all together, allowing developers to write clean, modular code. Modules can depend on and essentially extend each other, and we've been using it in production for almost 2 years now with great success. I'm looking into incorporating type-graphql, which graphql modules supports and has specific documentation on, which is how I found this bug.
The problem is, that when using type-graphql 1.0.0-rc.2, a resolver for [what I believe you refer to as a] "computed" field is not called, even though the schema is properly updated with that field definition.
To Reproduce
type-graphql resolver not called repro.zip
In the attachment above are two simple projects - one works, the other does not. The code in both projects is exactly the same, and the only difference is the version of type-graphql (and its peer dependency, graphql). Simply download and unzip, and for each of the two projects,
yarn
, andyarn local
. This will pull up playground on port 4000.When running the "working" project, execute the following query from playground:
You will get back:
This is the expected behavior.
Now, from the "broken" project, run the query again. You will receive error "Cannot return null for non-nullable field User.orders."
Expected Behavior
Result should be
Rather than error "Cannot return null for non-nullable field User.orders."
Logs
This is where I wish I could provide more help - I've tried logging out the outputs of the generated resolver, but am not getting anything useful. The best I can get is confirm that
typeof (new UserResolver()).orders
is "function", as expectedEnvironment (please complete the following information):
Additional Context
This could also be a bug with graphql, rather than type-graphql, but could use your help debugging and routing to the right place.
The text was updated successfully, but these errors were encountered: