-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
WIP: Refactor to remove global state #557
Conversation
@devknoll - great to see you're thinking about this! Moving away from singletons will have to be done incrementally to keep everything working in the interim, but we're happy to provide support and help guide you through these PRs. I can share an internal doc that I wrote detailing the high-level steps for removing singletons and global state, will follow-up tomorrow. |
👍 That'd be super. My current plan is something along the lines of: PR 1
PR 2
PR 3
This should hopefully make the process relatively pain free allowing the changes to flow upstream... |
@@ -506,4 +517,7 @@ function getRootCallToIDMap( | |||
} | |||
return mapping; | |||
} | |||
module.exports = GraphQLDeferredQueryTracker; | |||
|
|||
module.exports = new GraphQLDeferredQueryTracker( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export the class
This is a great start. My overall feedback is that any singleton module that is converted to a class should export the class, and all call sites of that module should be updated to either instantiate an instance or be passed one from somewhere. To help understand the implications of each change and make this reviewable, would you mind sending one PR per module? |
Ahhh, sorry, wasn't ready yet 😉 I avoided changing exports to avoid an explosion of changes, and to ensure all of the existing tests would keep passing 😄 |
Haha ok :-) Feel free to keep iterating here while you're exploring, and I'll add comments and feedback. When you're ready let's split into separate PRs. |
Can you clarify that you mean you want PRs at e.g. the |
They don't necessarily have to be exactly one PR per module, but try to think about ways to split it up into incremental changes. Note that |
@devknoll In addition to the previous issue to go with this PR, also take a look at #559 which describes our thoughts on drawing a clear boundary between Relay Core and the Relay/React integration. The proposed |
Closed this to open smaller & more focused PRs. |
Opening PR just to track progress and interest, and promote feedback and discussion. The plan is to factor out Relay's global state.
...ignore the failing tests 😄