Ошибка сети Apollo на Android устройстве (React Native) - PullRequest
0 голосов
/ 07 мая 2020

Итак, я играю с Expo + React Native + yoga graphql server + Apollo Client, получение данных с запросами работает в браузере, когда из Expo я нажимаю на «Run in Browser», но выдает ошибку сети, если я попробуйте запустить приложение на симуляторе android / qr-коде с реального телефона. PS Я читал похожие сообщения и проблемы на github, поэтому мне удалось сделать мою конечную точку graphql доступной извне с помощью nat и no-ip. (так что это не проблема localhost). Вот ошибка в console.log (ошибка):

Сетевая ошибка: сбой сетевого запроса
* http://192.168.1.55: 19001 / node_modules / expo / AppEntry.bundle? = android & dev = true & minify = false & hot = false: 159227: 30 в ApolloError
- node_modules/@apollo/client/apollo-client.cjs. js: 681: 35 в ObservableQuery.prototype .getCurrentResult
- node_modules/@apollo/client/apollo-client.cjs. js: 4957: 17 в _this.getQueryResult - node_modules/@apollo/client/apollo-client.c js. js: 5083: 24 в - node_modules/@apollo/client/apollo-client.cjs. js: 5235: 22 в использовании DeepMemo
- node_modules / @ apollo / client /apollo-client.cjs.js:5258:4 in useBaseQuery
* http://192.168.1.55: 19001 / node_modules / expo / AppEntry.bundle? platform = android & dev = true & minify = false & hot = false: 157867: 42 in - node_modules / react-native / Libraries / Renderer / implementation / ReactNativeRenderer-dev. js: 10696: 27 в renderWithHooks - node_modules / react -native / Libraries / Renderer / implementation / ReactNativeRenderer-dev. js: 12842: 6 в updateFunctionComponent - node_modules / react-native / Libraries / Renderer / реализация / ReactNativeRenderer-dev. js: 20459: 25 в beginWork $$ 1 - node_modules / react-native / Libraries / Renderer / implementation / ReactNativeRenderer-dev. js: 19370: 24 в performUnitOfWork
- node_modules / react-native / Libraries / Renderer / implementation / ReactNativeRenderer-dev. js: 19347: 39 в workLoopSyn c
- node_modules / react-native / Libraries / Renderer / implementation / ReactNativeRenderer-dev. js: 18997: 22 в рендере Root
* [собственный код]: null в renderRoot - node_modules / react-native / Libraries / Renderer / implementation / ReactNativeRenderer-dev. js: 18709: 28 в runRootCallback * [собственный код]: null в runRootCallback - node_modules / react-native / Libraries / Renderer / implementation / ReactNativeRenderer-dev. js: 5642: 32 в runWithPriority $ argument_1 - node_modules / scheduler / cjs / scheduler.development. js: 643: 23 в unstable_runWithPriority - node_modules / response-native / Libraries / Renderer / implementation / ReactNativeRenderer-dev. js: 5638: 22 в flushSyncCallbackQueueImpl - node_modules / response-native / Libraries / Renderer / implementation / ReactNativeRende59. *: 5627: 28 в flushSyncCallbackQueue- node_modules / react-native / Libraries / Renderer / implementation / ReactNativeRenderer-dev. js: 18556: 30 в scheduleUpdateOnFiber - node_modules / react-native / Libraries / Renderer / implementation / ReactNativeRende. js: 11484: 17 в dispatchAction * [собственный код]: null в dispatchAction - node_modules/@apollo/client/apollo-client.cjs. js: 5174: 26 в obsQuery.subscribe $ argument_0 .error - node_modules / zen-observable / lib / Observable. js: 139: 8 в notifySubscription * http://192.168.1.55: 19001 / node_modules / expo / AppEntry.bundle? platform = android & dev = true & minify = false & hot = false: 165854: 23 в onNotify - node_modules / zen-observable / lib / Observable. js: 239: 11 с ошибкой * [собственный код]: null для Каждый - node_modules/@apollo/client/apollo-client.cjs. js: 956: 4 в iterateObserversSafely * http://192.168.1.55: 19001 / node_modules / expo / AppEntry.bundle? Platform = android & dev = true & minify = false & hot = false: 159700: 31 в onError - node_modules/@apollo/client/apollo-client.cjs. js: 2424: 20 в invoke - node_modules/@apollo/client/apollo-client.cjs. js: 2785: 24 в info.listeners.forEach $ argument_0 * [ собственный код]: null в forEach - node_modules/@apollo/client/apollo-client.cjs. js: 2783: 34 в query.forEach $ argument_0 * [собственный код]: null в forEach - node_modules /@apollo/client/apollo-client.cjs.js:2781:8 в QueryManager.prototype.broadcastQueries * http://192.168.1.55: 19001 / node_modules / expo / AppEntry.bundle? platform = android & dev = true & minify = false & hot = false: 161498: 45 в - node_modules / обещание / setimmediate / core. js: 37: 14 в tryCallOne - node_modules / обещание / setimmediate / core. js: 123: 25 в setImmediate $ argument_0 - node_modules / react-native / Libraries / Core / Timers / JSTimers. js: 146: 14 в _callTimer - node_modules / react-native / Libraries / Core / Timers / JSTimers. js: 194: 17 в _callImmediatesPass - node_modules / react-native / Libraries / Core / Timers / JSTimers. js: 458: 30 в callImmediates * [собственный код]: null в callImmediates - node_modules /react-native/Libraries/BatchedBridge/MessageQueue.js:407:6 в __callImmediates - node_modules / react-native / Libraries / BatchedBridge / MessageQueue. js: 143: 6 в __guard $ argument_0 - node_modules / response-native /Libraries/BatchedBridge/MessageQueue.js:384:10 в __guard - node_modules / react-native / Libraries / BatchedBridge / MessageQueue. js: 142: 17 в __guard $ argument_0 * [собственный код]: null в flastedQueue * [собственный код]: null в callFunctionReturnFlastedQueue

что я делаю не так? : - (

1 Ответ

1 голос
/ 08 мая 2020

Получается, что если вы хотите сделать свою конечную точку graphql доступной из «внешнего мира», вы должны сделать это по https, потому что сервер expo работает по безопасному соединению и откажется загружать данные из небезопасного. Я пытался реализовать ssl поверх сервера graphql-yoga, но в конце концов было намного быстрее развернуть конечную точку graphql в облаке heroku или prisma, где https предлагается из коробки! Однако ошибка стека, которую я показал выше, не имела ничего общего с Apollo, не получавшим данные, поскольку она все еще выскакивает даже сейчас! Надеюсь, это поможет другим сэкономить время!

...