graphql - Graphql 响应不是来自 Apollo 客户端查询
问题描述
在我的本地http://localhost:3000/graphql查询中,如下所示...
但是当我通过 apollo 客户端查询时,它的响应是空的
import {InMemoryCache, gql, ApolloClient, HttpLink} from 'apollo-boost';
const cache = new InMemoryCache();
const client = new ApolloClient({
cache,
link: new HttpLink({
uri: 'http://localhost:3000/graphql',
credentials: 'same-origin',
}),
},
});
client
.query({
query: gql`
{
brands {
_id
}
}
`,
})
.then(data => console.log(data))
.catch(error => {
// its coming in this section
console.log(error);
});
不知道我错过了什么。感谢任何帮助谢谢!
下面是截图,当我试图从前端查询时
解决方案
通过添加 app.js 解决
global.XMLHttpRequest = global.originalXMLHttpRequest || global.XMLHttpRequest;
global.FormData = global.originalFormData || global.FormData;
if (window.FETCH_SUPPORT) {
window.FETCH_SUPPORT.blob = false;
} else {
global.Blob = global.originalBlob || global.Blob;
global.FileReader = global.originalFileReader || global.FileReader;
}
参考:https ://github.com/jhen0409/react-native-debugger/issues/382#issuecomment-544226529
推荐阅读
- php - 如何格式化必须写入 csv 文件 Codeigniter 的数据
- typo3 - 如何在标签或描述字段中的 Typo3 8.7 表单扩展中插入 html 代码
- typescript - 将“import * as”与 index.ts 结合使用
- javascript - CRC-16-IBM 实施 (JS) 不工作
- python - Django 最佳实践 - 比较用户
- google-chrome - 将 scrollTop 动画到窗口 onLoad 中的较低位置后,Chrome 跳回页面顶部
- javascript - 将另一个对象的属性作为参数的 Javascript 对象以某种方式更改它
- flutter - Flutter:自定义单选按钮
- performance - h2 如何在 Join 中选择正确/错误的索引
- php - 使用 Laravel Eloquent 构建复杂的 where 语句