apollo-directives-package

This is directives package for Apollo

Usage no npm install needed!

<script type="module">
  import apolloDirectivesPackage from 'https://cdn.skypack.dev/apollo-directives-package';
</script>

README

Apollo-directives-package

npm package

This is directives package for Apollo

Usage example

in .js

var { RenameDirective } = require('apollo-directives-package') // in VanillaJS(javascript)
// or
import { RenameDirective } from 'apollo-directives-package' // in ES

const schema = makeExecutableSchema({
  schemaDirectives: {
    ...
    rename: RenameDirective,
  }
})

in .ts

// in Typescript
import { RenameDirective } from 'apollo-directives-package'

const schema = makeExecutableSchema({
  schemaDirectives: {
    ...
    rename: RenameDirective, // if graphql-tools >= 3.x.x
    rename: RenameDirective as any, // if graphql-tools < 3.x.x
  }
})
type Query {
  getBook: Book
  anotherGetBook: Book @rename(type: "Query", to: "allBook")
}

type Mutation {
  createBook(title: "Apollo Directives Package"): Book
  newBook(title: "Apollo Directives Package"): Book @rename(type: "Mutation", to: "createBook")
}

Directives list

  1. RenameDirective: To rename(redirect) other Query, Mutation, Field resolve

Please pull-request to update your awesome directive!🤩 and give me your username in github, npm to register collaborators.

To Do

Bugs

  • Directive type is no match in Typescript -> Resolved.(Refer to version of graphql-tools)
makeExecutableSchema({
    schemaDirectives: {...} // <- type no match error in Typescript
})

License

Code copyright 2018 Yoonho Go. Code released under the MIT license.