Last active
April 30, 2016 03:33
-
-
Save helfer/72a8ff40dd106b842374492627b63094 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { applyDecorators } from 'graphql-tools'; | |
import { | |
GraphQLSchema, | |
GraphQLString, | |
GraphQLObjectType, | |
} from 'graphql'; | |
import { Doc, Log } from 'graphql-decorators'; | |
const Logger = { log: (...args) => console.log(...args) }; | |
const doc = new Doc(); | |
const log = new Log({ logger: Logger }); | |
const schema = new GraphQLSchema({ | |
query: new GraphQLObjectType({ | |
name: 'Query', | |
decorators: [ log.apply({prefix: 'query' }) ], | |
fields: { | |
aString: { | |
type: GraphQLString, | |
decorators: [ doc.apply({ description: 'Returns hello world' }) ], | |
resolve: () => 'Hello World', | |
} | |
} | |
}) | |
}); | |
// call applyDecorators to apply the decorators to the schema | |
applyDecorators(schema); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment