-
Notifications
You must be signed in to change notification settings - Fork 36
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
[Bug] SchemaLink and Async schema duplicated GraphQL instance #217
Comments
Reproduction:
My thoughts: I think it might have to do with the way I'm using the async import to get my |
I'm gonna guess that you're running into a dual package hazard with the I imagine your code is transpiled before being executed, so everything is a The only thing I can imagine right now to get around that dynamic You can see a simple example of that here in {
"exports": {
".": {
"types": "./index.d.ts",
"browser": "./empty.js"
"default": "./actualCode.js"
},
"./package.json": "./package.json"
},
} That way, the browser build would always pick this up as an empty file. I'm really sorry for all of these complications, but that's the sorry state the complexity of the React bundling experience puts us in right now. |
At this point given the requirement of the schema being generated async and this issue, RSC and Server Actions start to look more appealing, otherwise, I would have to stick to |
I'd love to have a better solution for you here - you are pretty much experiencing every pain the ecosystem has to offer :( That said, are you 100% sure that you need to dynamically import |
Well, the typings for the driver don't have an option that doesn't return a Promise (I might have to check the src and see if there's an internal sync option), meanwhile, I am wondering if trying to activate top-level await and maybe making the output target of TS be |
Based on #188 having a Schema that is created async will give us lots of problems trying to use
SchemaLink
, the current state is that we can avoid using an absolute URL for theHttpLink
if we useSchemaLink
on the SSR side, however, if the Schema is generated async we need to handle the promise before it even lands in theApolloNextAppProvider
'smakeClient
factory, which doesn't accept async factories.The following was recommended as a way to handle the promise properly, it works and the site renders properly, but the SSR side gives an error about multiple
graphql
instances and the render takes longer than usingHttpLink
with absolute URL:Tried the
use
anduseState
thing, it worked but suddenly got this kind of issue, I scanned the lock file, it should only exist a single version ofgraphql
in my app, maybe it is creating multiple instances?Originally posted by @luchillo17 in #188 (comment)
The text was updated successfully, but these errors were encountered: