0.0.7 • Published 3 years ago

graphql-codegen-svelte v0.0.7

Weekly downloads
1
License
MIT
Repository
-
Last release
3 years ago

Graphql generator for svelte-apollo - Fork of graphql-codegen-svelte-apollo

GraphQL Code Generator plugin to generate ts-ready svelte-apollo queries from graphql.

I played around with graphql-codegen-svelte-apollo and it was lacking support for the new svelte-apollo. Because svelte-apollo handles queries and mutations different now (from Promises => to loading/error/data).

Install

npm i -D graphql-codegen-svelte

Configuration

  • You don't need to set path to apollo client anymore, just call svelte-apollos setClient(client) in your _layout.svelte for sapper or App.svelte and you're good to go

Note: typescript and typescript-operations plugins are required.

Example config

overwrite: true
schema:
    - 'https://myschema/graphql'
documents:
    - 'src/**/*.{graphql,gql,ts}'
generates:
    output.ts:
        plugins:
            - 'typescript'
            - 'typescript-operations'
            - 'graphql-codegen-svelte-apollo'
hooks:
    afterAllFileWrite:
        - prettier --write

Usage example