Skip to content

Instantly share code, notes, and snippets.

@kumarharsh
Created February 20, 2017 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumarharsh/f0441514fe6f8e9c388abaa5a840956a to your computer and use it in GitHub Desktop.
Save kumarharsh/f0441514fe6f8e9c388abaa5a840956a to your computer and use it in GitHub Desktop.
Build schema.json from Graphql mutations & queries using playlyfe/go-graphql
package main
import (
"flag"
"io/ioutil"
"github.com/playlyfe/go-graphql"
gql "github.com/your-project/your-graphql-mutations-and-queries"
)
func main() {
flag.Parse()
gql, err := graphql.NewGraphQL(&graphql.GraphQLParams{
SchemaDefinition: gql.NewSchema(),
QueryRoot: "Query",
MutationRoot: "Mutation",
Resolvers: gql.New(),
Scalars: gql.NewScalars(),
ResolveType: gql.ResolveType,
})
if err != nil {
panic(err)
}
gql.Debug = true
err = ioutil.WriteFile("ui/schema.json", []byte(gql.PrintSchema()), 0644)
if err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment