question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New feature: TypeScript Svelte Apollo

See original GitHub issue

There is currently no support for Svelte, I propose a plugin to create a Svelte context to handle the ApolloClient that supports TypeScript. There is nothing complicated at this point, with only two possible parameters:

  • loadGetClientFrom takes getClient from the file pointed to for use with the ApolloClient
  • exportOnlyFunctions remove exports for graphql documents, data types, input & output formats ; the generated file exports getClient, setClient, query, mutation & subscription functions.

I propose a PR in 3 commits:

  1. Adding the plugin
  2. Add the plugin to the global configuration
  3. Add the plugin in the website

Edit: just pushed a complement for documentations. Hope you enjoy it !

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ticruz38commented, May 12, 2021

By reading the pull request, everything is pretty much the same, except you’re not using watchQueries (they work really well with svelte reactivity). You are using svelte context to bring the Apollo client, I’m not sure if this is really needed, you will run into problems when using this plugin with sapper/svelte-kit with SSR activated. It’s also why you need svelte as a dependency to your plugin.

0reactions
Urigocommented, Aug 8, 2021

@karkael64 closing for now as we haven’t heard back from you after @ticruz38 recent comment. If this still doesn’t solve your problem please feel free to comment here and reopen the issue and PR.

Also, regarding that, I wonder what Svelte developers think about the new near-operation-file-preset introduced in Codegen V2? Would be great to hear your feedback about that.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

typescript-svelte-apollo - GraphQL Code Generator
This plugin generates observable Apollo queries with Typescript typings. This is a community plugin, to report eventual issues or find more ...
Read more >
graphql-codegen-typescript-svelte-apollo - npm package - Snyk
GraphQL Code Generator plugin for generating ready-to-use Svelte-Apollo composition functions based on GraphQL operations For more information about how to ...
Read more >
graphql-codegen + typescript-svelte-apollo - Refetch not ...
(Edited) Refetching with the generated query type seems to work different from the refetch function in Apollo Client useQuery .
Read more >
svelte-apollo - npm
Latest version: 0.5.0, last published: 6 months ago. Start using svelte-apollo in your project by running `npm i svelte-apollo`.
Read more >
How to Setup Svelte with GraphQL, TypeScript and Material-UI?
Svelte is a Component Framework like React and Vue, that aims to compile ... new ApolloClient({ uri: 'http://localhost:8080/v1/graphql', ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found