-
-
Notifications
You must be signed in to change notification settings - Fork 810
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade apollo-client-devtools to v4 (#783)
* Initial work of upgrade apollo-client-devtools * Add prefix for all message types of apollo-client-devtools by patch * Middleware: Handle `ac-devtools:` prefix messages * Worker: Import devtools hook also add some patch to apollo-client-devtools: - Remove content script (it was attached to RNDebugger window) - No second arg on postMessage * Add apollo-client example * Fix tests * E2E: Take screenshot after each & upload artifacts on CI failed * E2E: Take devtools window screenshot * Fix typo in removeEventListener * Add test case for apollo-client-devtools
- Loading branch information
Showing
33 changed files
with
3,519 additions
and
1,160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ release/ | |
tmp/ | ||
config_test | ||
.idea/ | ||
artifacts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
/* | ||
* Create an Apollo Client to test the bridge messages sent | ||
* wouldn't break the debugger proxy. | ||
*/ | ||
|
||
/* eslint-disable */ | ||
import ApolloClient from 'apollo-boost'; | ||
import { ApolloClient, InMemoryCache } from '@apollo/client' | ||
import gql from 'graphql-tag' | ||
|
||
new ApolloClient({ | ||
uri: 'https://fakerql.com/graphql', | ||
}); | ||
const client = new ApolloClient({ | ||
uri: 'https://spacex-production.up.railway.app/', | ||
cache: new InMemoryCache(), | ||
}) | ||
|
||
export default async function run() { | ||
return client.query({ | ||
query: gql` | ||
query ExampleQuery { | ||
company { | ||
name | ||
ceo | ||
employees | ||
} | ||
} | ||
`, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import './setup' | ||
|
||
import runXHRTest from './xhr-test' // Install fetch polyfill before initial apollo-client | ||
import runApolloTest from './apollo' | ||
import runReduxTest from './redux' | ||
import runMobXTest from './mobx' | ||
import runRemoteDevTest from './remotedev' | ||
import runXHRTest from './xhr-test' | ||
import './apollo' | ||
|
||
runReduxTest() | ||
runMobXTest() | ||
runRemoteDevTest() | ||
runXHRTest() | ||
runApolloTest().catch((e) => console.error(e)) | ||
runXHRTest().catch((e) => console.error(e)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,5 @@ | ||
import Bridge from 'apollo-client-devtools/src/bridge' | ||
import { initBackend, sendBridgeReady } from 'apollo-client-devtools/src/backend' | ||
import { version as devToolsVersion } from 'apollo-client-devtools/package.json' | ||
import { getSafeAsyncStorage } from './asyncStorage' | ||
|
||
export function handleApolloClient({ NativeModules } = {}) { | ||
const interval = setInterval(() => { | ||
if (!self.__APOLLO_CLIENT__) { | ||
return | ||
} | ||
|
||
clearInterval(interval) | ||
|
||
const hook = { | ||
ApolloClient: self.__APOLLO_CLIENT__, | ||
devToolsVersion, | ||
} | ||
|
||
let listener | ||
|
||
const bridge = new Bridge({ | ||
listen(fn) { | ||
listener = self.addEventListener('message', (evt) => { | ||
if (evt.data.source === 'apollo-devtools-proxy') { | ||
return fn(evt.data) | ||
} | ||
}) | ||
}, | ||
send(data) { | ||
postMessage({ | ||
...data, | ||
source: 'apollo-devtools-backend', | ||
}) | ||
}, | ||
}) | ||
|
||
bridge.on('init', () => { | ||
sendBridgeReady() | ||
}) | ||
|
||
bridge.on('shutdown', () => { | ||
self.removeEventListener('message', listener) | ||
}) | ||
|
||
initBackend(bridge, hook, getSafeAsyncStorage(NativeModules)) | ||
}, 1000) | ||
return interval | ||
export function handleApolloClient() { | ||
// eslint-disable-next-line global-require | ||
require('apollo-client-devtools/build/hook') | ||
} |
Oops, something went wrong.