Closed
Description
While setting up svelte-apollo
with Sapper (#9), as there is no main App.svelte
component, I tried to set the client in the _layout.svelte
file.
<!-- _layout.svelte -->
<script lang="ts">
import { setClient } from "svelte-apollo";
import client from "../database/apollo";
setClient(client);
</script>
However, I get the following error:
Uncaught (in promise) Error: Function called outside component initialization
at get_current_component (index.mjs:629)
at setContext (index.mjs:659)
at setClient (svelte-apollo.es.js:14)
at _layout.svelte:33
at run (index.mjs:18)
at Array.map (<anonymous>)
at index.mjs:1390
at flush (index.mjs:723)
at init (index.mjs:1477)
at new App (App.svelte:17)
Where should I set the client instead?
Edit
In previous versions of v0.3.0
, the solution that #9 (comment) comments would work fine, but in v0.4.0
we must set the client with the proper method.
Metadata
Metadata
Assignees
Labels
No labels