Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.
/ graphql-codegen Public archive

Generates go code from graphql schema (to be used with github.com/neelance/graphql-go)

Notifications You must be signed in to change notification settings

Applifier/graphql-codegen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

graphql-codegen

This tool generates boilerplate code for graphql-go based on a provided graphql.schema file. Additional config file can be provided to customize output.

go install github.com/Applifier/graphql-codegen

TODO

  • Allow custom templates (without rebuilding)

example

Example below generates code for schema.graphql. Optional config config.hcl file is provided to tell the codegen where and how to fetch the data for the resolvers.

graphql-codegen generate -s=codegen/fixtures/httpget/schema.graphql -c=codegen/fixtures/httpget/config.hcl -p=httpget -o=test_output/

Example of the generated code (_gen.go files) can be found under /codegen/fixtures/httpget

templates

default

Resolve field based on a struct property with the same name as the schema type field

custom

Skips code generation for the field

Check example config and conversation.go

http_resolver

Resolve field with a http GET request to a server

type "Query" {
  field "user" {
    imports = ["\"fmt\""]
    template "http_resolver" {
      url = "fmt.Sprintf(\"https://static.everyplay.com/developer-quiz/data/users/%s\", args.ID)"
    }
  }
}

About

Generates go code from graphql schema (to be used with github.com/neelance/graphql-go)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published