@apollo/client配置问题
来源:7-8 配置 ESLint 并使用 Apollo 创建 GraphQL Service(中)

是李骏同学
2023-08-21
我照视频中教的配置client但是
浏览器抛错:
Uncaught SyntaxError: Unexpected string (at @apollo_client.js?v=de6dd3f3:1377:51)
配置如下:
import { ApolloClient, InMemoryCache } from '@apollo/client';
export const client = new ApolloClient({
uri: 'http://localhost:3000/graphql',
cache: new InMemoryCache(),
});
export default client;
使用场景
client
.query({
query: FIND,
variables: {
id: '6dbf878b-f0d8-4b81-b35c-7652f01ad719',
},
})
.then((result) => console.log(result));
这样写是看了apollo官方文档为了排查问题写的,位置在main.tsx中
服务器测试可用
写回答
1回答
-
黑石
2023-08-21
是因为版本不匹配奥,请使用我代码里的 pnpm lock文件,版本不匹配会导致报错。
也可以加入 qq 了解,因为你的很多问题,qq 群里都有讲。
https://coding.imooc.com/learn/questiondetail/4a9DdYaBRglXlpe0.html
032023-08-21
相似问题