From f42cf79443fd08f61385761f86ddeb0f914257e6 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Thu, 19 Jul 2018 15:27:55 +0200 Subject: start of a graphql schema+types --- graphql/schema.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'graphql/schema.go') diff --git a/graphql/schema.go b/graphql/schema.go index f6523f03..f8fb9768 100644 --- a/graphql/schema.go +++ b/graphql/schema.go @@ -3,15 +3,19 @@ package graphql import "github.com/graphql-go/graphql" func graphqlSchema() (graphql.Schema, error) { - fields := graphql.Fields{ - "hello": &graphql.Field{ - Type: graphql.String, - Resolve: func(p graphql.ResolveParams) (interface{}, error) { - return "world", nil + + rootQuery := graphql.ObjectConfig{ + Name: "RootQuery", + Fields: graphql.Fields{ + "hello": &graphql.Field{ + Type: graphql.String, }, }, } - rootQuery := graphql.ObjectConfig{Name: "RootQuery", Fields: fields} - schemaConfig := graphql.SchemaConfig{Query: graphql.NewObject(rootQuery)} + + schemaConfig := graphql.SchemaConfig{ + Query: graphql.NewObject(rootQuery), + } + return graphql.NewSchema(schemaConfig) } -- cgit