Skip to content

Instantly share code, notes, and snippets.

@helfer
Last active April 30, 2016 03:33
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 helfer/72a8ff40dd106b842374492627b63094 to your computer and use it in GitHub Desktop.
Save helfer/72a8ff40dd106b842374492627b63094 to your computer and use it in GitHub Desktop.
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