Skip to content

Instantly share code, notes, and snippets.

@sogko
Created November 2, 2015 16:52
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 sogko/a47c71711ed486dad15a to your computer and use it in GitHub Desktop.
Save sogko/a47c71711ed486dad15a to your computer and use it in GitHub Desktop.
graphql-go #35
import {
GraphQLSchema,
GraphQLObjectType,
GraphQLString,
GraphQLNonNull,
GraphQLList,
GraphQLBoolean,
GraphQLInt,
GraphQLFloat,
GraphQLEnumType,
GraphQLScalarType,
GraphQLInputObjectType,
GraphQLUnionType,
graphql
} from 'graphql'
import {
Kind
} from 'graphql/language'
import {
GraphQLError
} from 'graphql/error'
var UserType = new GraphQLObjectType({
name: 'User',
description: 'A typical user',
fields: {
id: {
type: GraphQLInt,
description: 'The id of the user'
},
}
})
var Schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: {
user: {
type: UserType,
resolve(user, args, root) {
return {
id: "test"
}
}
},
}
}),
})
graphql(Schema, 'query Test { user { id } }')
.then((result) => {
console.log(result)
})
// Output: { data: { user: { id: null } } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment