@jaredpalmer/graphql-codegen-golang

Graphql Code Generator plugin for generating Golang

Usage no npm install needed!

<script type="module">
  import jaredpalmerGraphqlCodegenGolang from 'https://cdn.skypack.dev/@jaredpalmer/graphql-codegen-golang';
</script>

README

GraphQL Code Generator plugin for Golang

This package is a fork of ctison/graphql-codegen-golang with support for GraphQL fragments. It does not support subscriptions

Roadmap

  • Generate types
  • Generate queries and mutations
  • Generate fragments
  • Generate subscriptions
  • Allow api client to accept a global http options (e.g. authorization header for a bearer token)

This package generates Golang types and requests which use:

Install

The package is published to @jaredpalmer/graphql-codegen-golang.

npm install -D @jaredpalmer/graphql-codegen-golang
yarn install -D @jaredpalmer/graphql-codegen-golang

Usage: codegen.yaml

schema: pkg/graphql/schema.graphql
documents: pkg/graphql/!(schema).graphql
generates:
  pkg/graphql/graphql.go:
    hooks:
      afterOneFileWrite: go fmt
    plugins:
      - graphql-codegen-golang:
          packageName: graphql # default

Configuration

Configuration source is at src/config.ts

Name Default Description
packageName graphql Name of the generated Golang package.

License

MIT