Skip to content

Instantly share code, notes, and snippets.

@sogko
Last active August 3, 2016 07:37
Show Gist options
  • Save sogko/02424a9d3388a47512a5 to your computer and use it in GitHub Desktop.
Save sogko/02424a9d3388a47512a5 to your computer and use it in GitHub Desktop.
hello-world-graphql-part-1 - Schema definition (golang)
package main
import (
"github.com/graphql-go/graphql"
)
var queryType = graphql.NewObject(graphql.ObjectConfig{
Name: "Query",
Fields: graphql.Fields{
"latestPost": &graphql.Field{
Type: graphql.String,
Resolve: func(p types.ResolveParams) interface{} {
return "Hello World!"
},
},
},
})
var Schema, _ = graphql.NewSchema(graphql.SchemaConfig{
Query: queryType,
})
var graphql = require('graphql');
var queryType = new graphql.GraphQLObjectType({
name: 'Query',
fields: {
latestPost: {
type: graphql.GraphQLString,
resolve: function () {
return 'Hello World!';
}
}
}
});
var schema = new graphql.GraphQLSchema({
query: queryType
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment