Skip to content

Instantly share code, notes, and snippets.

@koblas
Created August 3, 2018 14:12
Show Gist options
  • Save koblas/a5f3badbc502330e1c7ab149c36b88e2 to your computer and use it in GitHub Desktop.
Save koblas/a5f3badbc502330e1c7ab149c36b88e2 to your computer and use it in GitHub Desktop.
GraphQL Scheme base
package nresolver
import (
"github.com/graphql-go/graphql"
)
var queryConfig = graphql.NewObject(graphql.ObjectConfig{
Name: "Query",
// Must initialize to an empty set
Fields: graphql.Fields{},
})
var mutationConfig = graphql.NewObject(graphql.ObjectConfig{
Name: "Mutation",
// Must initialize to an empty set
Fields: graphql.Fields{},
})
// GetSchema returns the constructed graphql schema
func GetSchema() *graphql.Schema {
var schema graphql.Schema
schema, err := graphql.NewSchema(graphql.SchemaConfig{
Query: queryConfig,
Mutation: mutationConfig,
})
if err != nil {
panic(err)
}
return &schema
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment