Error: fetch-mock: No fallback response defined for POST to /graphql

环境: "@apollo/client": "^3.1.2","graphql": "^15.3.0","react": "^16.13.1",

在连接是一直报错

const client = new ApolloClient({
    uri: '/graphql',
    cache: new InMemoryCache(),
});


client
    .query({
        query: gql`
            {
                user(id:1) {
                    name,
                }
            }
    `
    })
    .then(result => console.log(result));

报错信息:

Error: fetch-mock: No fallback response defined for POST to /graphql_第1张图片

分析:使用fetch-mock模拟数据,访问被拦截

解决方式:移除fetch-mock

你可能感兴趣的:(GraphQl,React)