Created
February 20, 2017 13:38
-
-
Save kumarharsh/6bdbd01cbeb17dc1e896c221a9e81163 to your computer and use it in GitHub Desktop.
Build schema.json from Graphql mutations & queries using playlyfe/go-graphql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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