RevereCRE / relay-nextjs

⚡️ Relay integration for Next.js apps
https://reverecre.github.io/relay-nextjs/
MIT License
251 stars 30 forks source link

Wired components getServerInitialProps error when creating operation descriptor #81

Closed robertt closed 1 year ago

robertt commented 1 year ago

Hiya! First, thank you for all the work done on this lib - it has saved so much time and is a pleasure to use.

I'm investigating an issue in our codebase that has popped up, and while I'm not sure the root cause I've tracked it down to this line here. When I log what query is, it is of type ConcreteRequest, not { default: ConcreteRequest } like the code assumes. This obviously leads to issues since accessing .default on ConcreteRequest is undefined. I am very confused as there isn't anything I can see which could have changed this behavior and previously, this has worked fine.

Would be very happy to PR a quick fix to check for the existence of default, but it's probably a better idea to figure out why this is happening/what as changed. Maybe a minor patch somewhere which gets automatically upgraded as this library is using non-obvious APIs in some cases?

As a sanity check, when I change the compiled js from const operationDescriptor = relay_runtime_1.createOperationDescriptor(query.default, variables); to const operationDescriptor = relay_runtime_1.createOperationDescriptor(query, variables); everything works fine.

rrdelaney commented 1 year ago

@robertt I appreciate the kind words, and thank you for the bug report! I think this could be a difference between SWC and Webpack? At Revere we're still on Webpack due to some straggling dependencies so it would explain why we've never seen this.

Would be very happy to PR a quick fix to check for the existence of default

Would gladly accept such a PR!

robertt commented 1 year ago

Agreed, although this has worked in the past with our SWC setup. I spent a bunch of time yesterday trying to figure out why this is happening but didn't get anywhere, so will accept defeat for now and move on with a blind fix - #82