Hi,
I was using version 2.6.9 previously before upgrading to the recent 3.0.0 rc4 and I have a weird error.
When I use my schema type with the bridge, it gives me this error in my console.
Error: Cannot use GraphQLInputObjectType "LoginWithPasswordInput" from another module or realm.
When I did a check of the type in your example and mine it differs, mine is GraphQLInputObjectType and the type in your example is GraphQLObjectType.
I assume there was a change in the underlying code?
I use buildClientSchema from graphql utilities in order to build my schema on the client side and then use schema.getType but the type returned doesn't seem to be the same as the one in your example.
Am I missing something?
Hope you can help, thanks!
Hi @simplecommerce. Using *InputType type instead of a _normal_ *Type should work just fine. Could you check, which version of graphql are you using? Starting in v3.0.0-rc.3 uniforms will use graphql@15. It may be the case that your application resolves a different version.
If it still won't work, please include a stack trace of this error.
@radekmie Yeah I thought that also, here is what I am using
├── [email protected]
└─┬ [email protected]
└── [email protected] deduped
The error is weird I had never seen it before.
@radekmie don't know if it could be related but one thing I noticed in my logs is that the astNode field is undefined in my Input or Post types, but when I use your example with buildASTSchema(parse(schema)).getType('Post');, the astNode field is populated.
I don't know if this matters or not
This is the complete error in my console
Uncaught Error: Cannot use GraphQLInputObjectType "LoginWithPasswordInput" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
at instanceOf (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:8697)
at isInputObjectType (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:20572)
at modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:176097
at Array.reduce (<anonymous>)
at GraphQLBridge.getField (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:176091)
at GraphQLBridge.memoized [as getField] (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:50428)
at useField (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:164415)
at TextField (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:164349)
at renderWithHooks (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:107603)
at mountIndeterminateComponent (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:110282)
at beginWork (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:111396)
at HTMLUnknownElement.callCallback (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:92988)
at Object.invokeGuardedCallbackDev (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:93037)
at invokeGuardedCallback (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:93092)
at beginWork$1 (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:116003)
at performUnitOfWork (modules.js?hash=da8eab1cb2712065daa5a2025a547eea7de0e6dd:114954)
@simplecommerce Maybe try to rebuild node_modules? Or even purge both node_modules and package-lock.json (or your packager equivalent). As I found out, it's most certainly a problem with multiple copies of graphql module.
About the astNode - we are not using it.
@simplecommerce Maybe try to rebuild
node_modules? Or even purge bothnode_modulesandpackage-lock.json(or your packager equivalent). As I found out, it's most certainly a problem with multiple copies ofgraphqlmodule.About the
astNode- we are not using it.
I tried that already unfortunately, removed node_modules and package-lock, still get the same error, its really odd
@simplecommerce Maybe it's your bundler then? As uniforms require only graphql/type/definition, try to import it in your app directly. I believe it could be some tree-shaking problem.
@simplecommerce Also, are you using some build-time transform for GraphQL? It may be the culprit as well.
@radekmie I don't think so, all I do on my client end is
client.__schema = buildClientSchema({ __schema: window.__APOLLO_CLIENT_SCHEMA__ });
which grabs my introspect query result and builds it so I can use the schema with my forms.
and then use the getType in order to use them.
it was working on the previous version before I actually switched in order to use useForm
it is really odd, I am doing some research and tests in order to see why it keeps giving me that error.
I tried "hardcoding" the LoginWithPasswordInput with the same example you provided and I still get the same error message, so I am trying to trace down what else is causing it.
@simplecommerce OK, do try to find out, what happens. I'll think about how to proceed here.
@radekmie does this make any sense to you?

It seems to throw an error here because valueClass.name and className are the same, but I don't get that logic at all and why.
Hmm I have the same issue here in a test sandbox using your example in the docs.
https://codesandbox.io/s/gifted-forest-6vn7j?file=/src/App.js
OK, so the problem is that one code loads the .mjs version and the other the .js one. I guess it's because we are using graphql/type/definition instead of graphql. I don't have a solution now (other than importing graphql instead).
@radekmie I am not sure I understand what I should do, can you show me what I should do in the sandbox?
@simplecommerce Well, I'm not sure how to test it. You'd need to somehow force the bundler to use one version only (e.g. disable .mjs completely). As I said, I can't see another way to confirm it besides reverting this import.
@radekmie I think you may be right, I tried doing a copy/paste of the source of the bridge and create my own by changing the import and it seems to load, but now it doesn't seem to catch the errors from the validator function.
https://codesandbox.io/s/gifted-forest-6vn7j
Maybe I did something wrong.
@simplecommerce Starting in v3.0.0-rc.3 you should return the error instead of throwing it. And the fact that it works with a copied source means that the bundling fails. I'll think about it.
@radekmie Thank you for your help!!
@simplecommerce I wanted to confirm what happens locally and I cannot reproduce it locally. I've downloaded your CodeSandbox, installed dependencies, tried started the project (either dev server or production build) and it works. I've tried both npm and yarn. I'm really confused now. Could you prepare a reproduction repo, that I could clone and run locally?
@radekmie Unfortunately I don't have a local repo that you could test with other than the codesandbox, it was my attempt to test and see if I could reproduce the issue on another repo. The one I had the issue on, is our company project, so I wouldn't be able to create a local repo for that.
Don't know if this can help.
I use meteorjs 1.11 with node/npm: v12.18.3/6.14.6
It runs on Ubuntu 18.04.1 LTS 18.04.
I don't know if on codesandbox if we can get the info that it builds the repo on?
@radekmie I will try to see if I can reproduce it using the codesandbox on my end locally.
@radekmie I downloaded a zip of the codesandbox and did npm install and I am not able to reproduce the error either.
But when I do it on the sandbox or in my project, the error occurs. It is really weird, I assume it has to be very specific in order to happen but I don't know why.
@simplecommerce I'm about to release probably the last RC version of v3. I've tried once again, but I'm still not able to reproduce this error. If you can - we'll be more than happy to fix it. Right now, all I can say is that I _think_ it's bundler related (and my previous findings confirm that).
@radekmie I am running into the same issue as @simplecommerce
I am using Meteor version 1.11
Npm packages:
Schema definition:
const schema = `
type EmailTemplateForm {
_id: String!
content: String!
}
# This is required by buildASTSchema
type Query { anything: ID }
`;

I use npm-force-resolutions to ensure everything resolves to graphql version 15.0.0.
@GoaGit could you create a reproduction repo that I could clone and work with? That'd be great!
@radekmie I posted a discussion on codesandbox with the sample app to see if they can help explain why or what the differences are between their live sandbox and the downloaded zip package. Since I am not able to reproduce the issue with that sample app on my end either. I hope it helps hint out what the issue is.
@radekmie I created a minimal repo where the issue shows up. You should first install Meteor version 1.11, run meteor npm install and the meteor.
@GoaGit Thank you! I confirm, this repo correctly reproduces this error. I'll keep you posted.
@radekmie in case it interests you https://github.com/codesandbox/codesandbox-client/discussions/4958#discussioncomment-88390
Seems to be exactly what you've said.
@radekmie based on the codesandbox finding, I opened up an issue on meteorjs github to see if they can help fix the issue.
@simplecommerce Great! Do mention this issue there so others could find it as well.
I think we can close this one for now - thanks again for mentioning it in the other issues so others can follow!
Most helpful comment
@GoaGit Thank you! I confirm, this repo correctly reproduces this error. I'll keep you posted.