apollo-directives
Custom graphQL directives for Apollo
🎉 Installation
npm i apollo-directives# or yarn add apollo-directives
📙 Directives
renameField, camelCase, capitalize, lowerFirst, toLower, toUpper, trim, upperFirst
✍ Example Usage
Add schemaDirectives
to your server
const ApolloServer = const renameField upperFirst toUpper toLower trim = const server = schemaDirectives: renameField upperFirst toUpper toLower trim ... context typeDefs resolvers dataSources;
Include and use directives
in your typeDefs
const gql = ; const typeDefs = gql` directive @renameField(name: String!) on FIELD_DEFINITION directive @upperFirst on FIELD_DEFINITION directive @toLower on FIELD_DEFINITION directive @trim on FIELD_DEFINITION directive @toUpper on FIELD_DEFINITION type Person { myCustomField: String! @renameField(name: "original_api_field_name") firstName: String! @upperFirst lastName: String! @upperFirst title: String! @toUpper address: String! @trim state: String! @toLower }`;
👷 Work in progess
Warning: This library is still a WIP. This is a beta version.
❓ Questions/Comments
Feel free to reach out ~ ferdelamad