-
Notifications
You must be signed in to change notification settings - Fork 114
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
[v1] Weird behaviour when extending createSchemaForApollo's schema #1725
Comments
|
I tried, but I get |
@darkbasic Because you still need the context. |
So basically graphql-modules v1 is a no go for libraries who also want to target non graphql-modules users who wish to use Apollo Server: I cannot realistically expect them to manually setup weakmaps :( |
Would be possible to wrap the schema with createSchemaForApollo after letting the user to merge it with its own schema? |
You can use |
Describe the bug
I'm upgrading accounts-js to graphql-modules v1. Accounts-js will use v1 internally, but it still needs to supports users who don't want to make use of graphql-modules in their projects. These users, instead of creating their own graphql module, will simply merge their typedefs/resolvers with those provided by accounts-js.
Basically users who want to use graphql-modules will use something like this:
while users who don't want to use graphql-modules will use something like this:
While the former works flawlessly, the latter shows some weird behaviour.
In this example the user wants to extend the
User
type provided by accounts-js with additional fields:If I look at the generated schema in GraphiQL I can see that the type has been extended correctly:
but for some reason it doesn't return those types when I run the
authenticate
mutation:Cannot return null for non-nullable field User.firstName
.This is weird because in all the top level resolvers this field has been provided but somehow it's missing once it reaches the User resolver:
Everything works flawlessly with the former approach (the user creates its own graphql-module).
I tried without
createSchemaForApollo
but I've gotcontext.ɵgetModuleContext is not a function
.To Reproduce
Steps to reproduce the behavior:
This is the accounts-js branch with graphql-modules v1: https://github.com/darkbasic/accounts/tree/f40419e14030f887066e34d1d454aa5f23cb931c
Expected behavior
There should be a way to be able to extend the typedefs/resolvers from a project which uses graphql-modules in a project which makes use of apollo-server but not graphql-modules itself. What am I doing wrong?
Environment:
@graphql-modules/1.4.2
:The text was updated successfully, but these errors were encountered: