Graphql-tools: Need docs for directive resolvers

Created on 12 Dec 2017  路  6Comments  路  Source: ardatan/graphql-tools

518 by @giautm added a new feature that's shipping in 2.13.0, we need docs for it though! I propose a new page called "Schema directives" to document this stuff.

To run the docs:

  1. Go to /docs in the repo
  2. git submodule init && git submodule update
  3. npm install
  4. npm start

Adding a page can be done by:

  1. Adding a file in the docs/source directory
  2. Adding an entry with the filename to docs/_config.yml
  3. Don't forget to put the title/description like so: https://raw.githubusercontent.com/apollographql/graphql-tools/master/docs/source/mocking.md
docs

Most helpful comment

@giautm Thanks for your example code. There is a typo in your code.

Wrong

attachDirectiveResolvers(
  schema,
  directiveResolvers,
});

Should be

attachDirectiveResolvers(schema, directiveResolvers);

All 6 comments

This one can be also solved with directives and is a good example of this great feature.

Yeah it can definitely be a good approach to authorization!

@giautm neat!! want to send that as a PR? If not I'll get around to copy-pasting it next week

@giautm Thanks for your example code. There is a typo in your code.

Wrong

attachDirectiveResolvers(
  schema,
  directiveResolvers,
});

Should be

attachDirectiveResolvers(schema, directiveResolvers);

Can directive has parameters?
If so, please give me code example

@Altiano: I opened a PR for the document. Please check it, and you can check tests for more examples.

Was this page helpful?
0 / 5 - 0 ratings