Skip to content

Instantly share code, notes, and snippets.

@sogko sogko/test.js

Created Nov 2, 2015
Embed
What would you like to do?
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
You can’t perform that action at this time.