Can anybody help me understand why i'm getting this error:
My setup :
New sveltekit project. ASP.net core backend for graphql. Querying was working before I modified it to include subscriptions.
error msg:
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
Source Code 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);
}
Thankyou for any help.