{"id":47827,"library":"graphql-codegen-svelte-apollo","title":"graphql-codegen-svelte-apollo","description":"GraphQL Code Generator plugin for generating fully typed Apollo client queries as reactive Svelte stores. Version 1.1.0, maintained. Key differentiator: integrates Apollo's reactive system with Svelte stores, enabling auto-refetch on variable changes. Works with @graphql-codegen/cli ecosystem. Supports observable and async queries via config.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/ticruz38/graphql-codegen-svelte-apollo","tags":["javascript","svelte","apollo","graphql","graphql-codegen"],"install":[{"cmd":"npm install graphql-codegen-svelte-apollo","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-codegen-svelte-apollo","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-codegen-svelte-apollo","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for code generation","package":"graphql","optional":false},{"reason":"required in devDependencies to run codegen","package":"@graphql-codegen/cli","optional":true},{"reason":"prerequisite plugin for TypeScript types","package":"@graphql-codegen/typescript","optional":true},{"reason":"prerequisite plugin for operation types","package":"@graphql-codegen/typescript-operations","optional":true}],"imports":[{"note":"Generated queries are named exports, not default exports.","wrong":"import Transactions from './generated'","symbol":"generated query (e.g. Transactions)","correct":"import { Transactions } from './generated'"},{"note":"clientPath config expects a file with default export named 'client'.","wrong":"import { client } from './apollo-client'","symbol":"apollo client (default export)","correct":"import client from './apollo-client'"},{"note":"TypeScript type import only; no runtime value.","wrong":"const { CodegenConfig } = require('@graphql-codegen/cli')","symbol":"graphql-codegen config","correct":"import type { CodegenConfig } from '@graphql-codegen/cli'"}],"quickstart":{"code":"// codegen.yml\nschema: './schema.graphql'\ndocuments: './src/**/*.graphql'\ngenerates:\n  ./src/generated.ts:\n    plugins:\n      - typescript\n      - typescript-operations\n      - graphql-codegen-svelte-apollo\n    config:\n      clientPath: './apollo-client'\n\n// Run: npx graphql-codegen\n\n// In Svelte component:\n<script lang=\"ts\">\n  import { Transactions } from './generated';\n  import client from './apollo-client';\n  let address = '0x0000000000000000000000000000';\n  $: t = Transactions({ address, client });\n</script>\n\n<ul>\n  {#each $t?.data?.transactions || [] as transaction}\n    <li>{transaction.from} to {transaction.to}</li>\n  {/each}\n</ul>","lang":"typescript","description":"Configures codegen to generate Svelte Apollo stores and demonstrates reactive query usage in a component."},"warnings":[{"fix":"Pass { client } object to generated query functions explicitly.","message":"In v1.0.0, the 'client' parameter is now required in generated functions.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Consider migrating to observable queries or use the 'asyncQuery' config as documented.","message":"asyncQuery option may be deprecated in future versions.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use the $ prefix to reactively read the store value in Svelte templates.","message":"Generated queries are reactive Svelte stores; accessing $t is required to subscribe.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure the file has 'export default client;' where client is new ApolloClient(...).","message":"clientPath must point to a file that exports an ApolloClient instance as default export.","severity":"gotcha","affected_versions":"all"},{"fix":"Use other GraphQL Codegen plugins for mutations/subscriptions.","message":"This plugin only generates client-side queries; mutations and subscriptions are not supported.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'/cli':46 '1.1.0':22 'apollo':5,14,27,57 'async':51 'auto':36 'auto-refetch':35 'chang':40 'client':15 'code':7 'codegen':3,45,61 'config':54 'differenti':25 'ecosystem':47 'enabl':34 'fulli':12 'generat':8,11 'graphql':2,6,44,58,60 'graphql-codegen':43,59 'graphql-codegen-svelte-apollo':1 'integr':26 'javascript':55 'key':24 'maintain':23 'observ':49 'plugin':9 'queri':16,52 'reactiv':18,29 'refetch':37 'store':20,33 'support':48 'svelt':4,19,32,56 'system':30 'type':13 'variabl':39 'version':21 'via':53 'work':41","created_at":"2026-06-07T16:53:31.438880+00:00","updated_at":"2026-06-07T16:53:31.438880+00:00","problems":[{"fix":"Run npm install -D graphql-codegen-svelte-apollo and ensure plugin name matches exactly.","cause":"Missing installation or incorrect plugin name in codegen.yml","error":"Cannot find module 'graphql-codegen-svelte-apollo'"},{"fix":"Pass { client } as the first argument, e.g., Transactions({ client }).","cause":"Generated function called without client object","error":"Error: Must provide 'client' argument to generated query function"},{"fix":"Ensure clientPath points to a file exporting an ApolloClient instance.","cause":"Client instance is not an ApolloClient","error":"TypeError: Cannot read properties of undefined (reading 'watchQuery')"},{"fix":"Use $t instead of t in Svelte template.","cause":"Missing the $ prefix when accessing generated store","error":"Uncaught (in promise) Error: Store is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/ticruz38/graphql-codegen-svelte-apollo#readme","github":"https://github.com/ticruz38/graphql-codegen-svelte-apollo","docs":null,"changelog":null,"pypi":null,"npm":"graphql-codegen-svelte-apollo","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}