Skip to content

Conversation

Gongreg
Copy link
Contributor

@Gongreg Gongreg commented Jan 9, 2019

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.

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
@apollo-cla
Copy link

@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) => {
Copy link
Member

@benjamn benjamn Jan 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea @benjamn, I will implement it today!

@Gongreg
Copy link
Contributor Author

Gongreg commented Jan 10, 2019

Hey, @benjamn,
I've updated the code. I see that for devtools version the version is taken out of manifest.json.

I am not sure it is the right thing to do to try to get it the same way in react native.
So what I assume is that the version will be in package.json (since it has to have a version). Is that okay?

Copy link
Contributor

@cheapsteak cheapsteak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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__);`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a comment here as well to explain what __APOLLO_DEVTOOLS_SHOULD_DISPLAY_PANEL__ is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Gongreg
Copy link
Contributor Author

Gongreg commented Jan 25, 2019

Hey @cheapsteak, I've added the comments :)

Copy link
Contributor

@cheapsteak cheapsteak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@Gongreg
Copy link
Contributor Author

Gongreg commented Jan 25, 2019

Yea, that would be great.
Then I will do final checks with the react native debugger itself and it should be good to go :)

(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?

@cheapsteak
Copy link
Contributor

That sounds great :D
Yup I can do that

@cheapsteak cheapsteak merged commit cc05e07 into apollographql:master Jan 25, 2019
@cheapsteak
Copy link
Contributor

@Gongreg published under 2.1.7-alpha.0 for now for testing 🙏

@Gongreg
Copy link
Contributor Author

Gongreg commented Jan 25, 2019

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

@cheapsteak
Copy link
Contributor

cheapsteak commented Jan 25, 2019

@Gongreg apologies, my bad 🤦‍♂️
just published alpha.1

@Gongreg
Copy link
Contributor Author

Gongreg commented Jan 25, 2019

@cheapsteak Just tested things out. It works! :) Going to try to get the react-native-debugger pr to be merged as soon as possible :)

@Gongreg Gongreg deleted the apollo branch January 25, 2019 22:19
@Gongreg
Copy link
Contributor Author

Gongreg commented Jan 25, 2019

@cheapsteak , one more issue. We need to have dist directory in shells/webextension, since we use the panel in react native debugger.

@cheapsteak
Copy link
Contributor

Ah, that makes sense
We could probably add that as a prepublish hook, and also add it to gitignore
You might have more familiarity with this repo than Justin and I do at the moment 😛, do you know if running the build script would be sufficient? Or would we need to add a new script?

@Gongreg
Copy link
Contributor Author

Gongreg commented Jan 28, 2019

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.

@justinanastos
Copy link
Contributor

#169

@cheapsteak
Copy link
Contributor

Published alpha.2 that includes the dist folder
https://unpkg.com/[email protected]/shells/webextension/dist/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants