Repository navigation
Adding code necessary for React Native support - #165
Conversation
Displays panel if __APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__ is set to true. Moved out hook to the backend files, so we could reuse src/backend/index in react native too.
# Conflicts: # shells/dev/src/backend.js # shells/webextension/src/backend.js
|
@Gongreg: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
| } | ||
| let uuid = genUuid(); | ||
|
|
||
| export const checkVersions = (hook, bridge) => { |
There was a problem hiding this comment.
The main question I have is uuid in check versions is used for? This code is not easy to implement in React Native, since it doesn't have localStorage but instead asyncStorage which is, well, async.
It seems like checkVersions ultimately does an async fetch call, so perhaps we could store the uuid using a generic async local storage API (backed by sync localStorage in browsers, but asyncStorage in RN), and then just hide the async access within the already-async behavior of checkVersions?
There was a problem hiding this comment.
Great idea @benjamn, I will implement it today!
|
Hey, @benjamn, I am not sure it is the right thing to do to try to get it the same way in react native. |
cheapsteak
left a comment
There was a problem hiding this comment.
This looks great 👍
Would appreciate if you could add a few comments to clarify some things that might not make sense unless you think about the package as something that'll be imported from somewhere else 🙏
| let connected; | ||
| let storage; | ||
|
|
||
| export const sendBridgeReady = () => { |
There was a problem hiding this comment.
Would you mind adding a comment here to explain why this function exists and is exported instead of inlined into the call site 🙏? I assume this is so the react native debugger can import and call this :)
| panelShown = false; | ||
| chrome.devtools.inspectedWindow.eval( | ||
| `!!(window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__.ApolloClient);`, | ||
| `!!(window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__.ApolloClient || window.__APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__);`, |
There was a problem hiding this comment.
Would you mind adding a comment here as well to explain what __APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__ is?
There was a problem hiding this comment.
Hey, since there is no Apollo client in the window context of react native debugger (the react native code with apollo is ran in a separate worker), we can't check for APOLLO_DEVTOOLS_GLOBAL_HOOK. To make it explicit I add a separate flag.
|
Hey @cheapsteak, I've added the comments :) |
cheapsteak
left a comment
There was a problem hiding this comment.
Thanks so much for the contribution!
Looking forward to seeing this work with React Native Debugger :D
Do we need to publish a new version to npm after merging?
|
Yea, that would be great. (I've worked on two projects, while doing changes both in checked out projects and in node_modules, in two different machines, so there is a big chance I might have missed something :D) Can you notify me when the new npm version is published? |
|
That sounds great :D |
|
@Gongreg published under 2.1.7-alpha.0 for now for testing 🙏 |
|
hey @cheapsteak, seems like the release didn't go well. I still get the code without the PR in 2.1.7-alpha.0 . https://registry.npmjs.org/apollo-client-devtools/-/apollo-client-devtools-2.1.7-alpha.0.tgz |
|
@Gongreg apologies, my bad 🤦♂️ |
|
@cheapsteak Just tested things out. It works! :) Going to try to get the react-native-debugger pr to be merged as soon as possible :) |
|
@cheapsteak , one more issue. We need to have dist directory in shells/webextension, since we use the panel in react native debugger. |
|
Ah, that makes sense |
|
Truth to be told I don't know which option is better. I've never worked on the module before this PR. But adding it as a build step sounds reasonable. I will create a separate issue and assign you, so it wouldn't be forgotten. |
|
Published alpha.2 that includes the dist folder |
In React Native debugger we create our own Bridge that we want to use with apollo dev tools.
I've updated the code to allow to setup custom bridge.
The main question I have is uuid in check versions is used for? This code is not easy to implement in React Native, since it doesn't have localStorage but instead asyncStorage which is, well, async.
Of course for RN we also need to solve #160.