谁能帮我理解为什么我会收到这个错误:
我的设置:
新的 sveltekit 项目。graphql 的 ASP.net 核心后端。在我修改它以包含订阅之前,查询是有效的。
错误信息:
Cannot read property 'executeQuery' of null
TypeError: Cannot read property 'executeQuery' of null
at C:\Repos\AGScada\node_modules\@urql\svelte\dist\urql-svelte.js:234:11
at C:\Repos\AGScada\node_modules\wonka\dist\wonka.js:254:18
at Object.next (C:\Repos\AGScada\node_modules\wonka\dist\wonka.js:1161:14)
at C:\Repos\AGScada\node_modules\@urql\svelte\dist\urql-svelte.js:173:11
at Object.subscribe (C:\Repos\AGScada\node_modules\svelte\store\index.js:53:9)
at Object.subscribe (C:\Repos\AGScada\node_modules\@urql\svelte\dist\urql-svelte.js:96:14)
at C:\Repos\AGScada\node_modules\@urql\svelte\dist\urql-svelte.js:168:14
at C:\Repos\AGScada\node_modules\wonka\dist\wonka.js:1159:9
at C:\Repos\AGScada\node_modules\wonka\dist\wonka.js:247:7
at C:\Repos\AGScada\node_modules\wonka\dist\wonka.js:590:18
源代码 index.svelte:
import { setClient, query, operationStore, subscription } from '@urql/svelte';
import { createClient, defaultExchanges, subscriptionExchange } from '@urql/svelte';
import { createClient as createWSClient } from 'graphql-ws';
const wsClient = process.browser ? createWSClient({url: 'ws://localhost:5000/graphql',}):null;
const client = process.browser ? createClient({
url: 'http://localhost:5000/graphql',
exchanges: [
...defaultExchanges,
subscriptionExchange({
forwardSubscription: (operation) => ({
subscribe: (sink) => ({
unsubscribe: wsClient.subscribe(operation, sink),
}),
}),
}),
],
}): null;
let tags = operationStore(`query {tags{tagName value}}`);
let onTagUpdated = operationStore(`subscription {onTagUpdated{tagName value}}`);
query(tags);
subscription(onTagUpdated);
setClient(client);
if($tags.fetching)
{
console.log("loading");
}
else
{
console.log($tags.data);
}
感谢您的任何帮助。