Skip to content

yoonhoGo/apollo-directives-package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

GraphQL directives package for Apollo GraphQL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published