Created
November 2, 2015 16:52
-
-
Save sogko/a47c71711ed486dad15a to your computer and use it in GitHub Desktop.
graphql-go #35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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